diff options
Diffstat (limited to 'cpp/demo/Database/Oracle')
-rw-r--r-- | cpp/demo/Database/Oracle/occi/Client.cpp | 606 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp | 72 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/DeptFactoryI.h | 8 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/DeptI.cpp | 92 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/EmpI.cpp | 120 | ||||
-rwxr-xr-x | cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp | 54 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/Server.cpp | 48 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/Util.cpp | 66 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/occi/Util.h | 4 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Client.cpp | 606 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc | 82 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptFactoryI.pc | 28 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/DeptI.pc | 52 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/EmpI.pc | 34 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Server.pc | 14 | ||||
-rw-r--r-- | cpp/demo/Database/Oracle/proc/Util.pc | 4 |
16 files changed, 945 insertions, 945 deletions
diff --git a/cpp/demo/Database/Oracle/occi/Client.cpp b/cpp/demo/Database/Oracle/occi/Client.cpp index 2260decdd0b..569fdf620fc 100644 --- a/cpp/demo/Database/Oracle/occi/Client.cpp +++ b/cpp/demo/Database/Oracle/occi/Client.cpp @@ -63,32 +63,32 @@ HRClient::HRClient() : _currentMenu(rootMenu) { _commonCommands = - "dept <number>: set department <number> as the current department\n" - "emp <number>: set employee <number> as the current employee\n" - "exit or quit: exit client\n" - "help: print this list of commands\n" - "root: go back to the root menu\n"; + "dept <number>: set department <number> as the current department\n" + "emp <number>: set employee <number> as the current employee\n" + "exit or quit: exit client\n" + "help: print this list of commands\n" + "root: go back to the root menu\n"; _rootCommands = - "create: create a new department\n" - "find <name>: find the department(s) with the given name\n" - "list: list all departments\n"; + "create: create a new department\n" + "find <name>: find the department(s) with the given name\n" + "list: list all departments\n"; - + _deptCommands = - "create: create a new employee in this department\n" - "find <name>: find employee(s) named <name> in this department\n" - "list: list all employees in this department\n" - "ping: ping this department\n" - "remove: remove this department\n" - "show: describe this department\n" - "update <dname|loc> <new value>: update this department\n"; + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "ping: ping this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update <dname|loc> <new value>: update this department\n"; _empCommands = - "ping: ping this employee\n" - "remove: remove this employee\n" - "show: describe this employee\n" - "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; + "ping: ping this employee\n" + "remove: remove this employee\n" + "show: describe this employee\n" + "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; } void @@ -96,13 +96,13 @@ HRClient::checkEof(const string& command) const { if(!cin.eof()) { - string extra; - getline(cin, extra); - if(extra.size() > 0) - { - cout << "Warning: ignoring extra args '" << extra - << "' for '" << command << "'" << endl; - } + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } } } @@ -111,10 +111,10 @@ HRClient::checkCin(const string& command) const { if(!cin) { - cout << "Error: failed to read arguments for '" << command << "'" << endl; - cin.clear(); - cin.ignore(numeric_limits<streamsize>::max(), '\n'); - return false; + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; } checkEof(command); return true; @@ -124,7 +124,7 @@ void HRClient::invalidCommand(const string& command) const { cout << "Invalid command '" << command << "'. " - "Type 'help' for help." << endl; + "Type 'help' for help." << endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); } @@ -136,21 +136,21 @@ HRClient::help() const switch(_currentMenu) { - case rootMenu: - { - cout << _rootCommands; - break; - } - case deptMenu: - { - cout << _deptCommands; - break; - } - case empMenu: - { - cout << _empCommands; - break; - } + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } } cout << "--- Common to all menus ---\n"; cout << _commonCommands << endl; @@ -163,8 +163,8 @@ HRClient::run(int argc, char* argv[]) _factory = DeptFactoryPrx::checkedCast(base); if(_factory == 0) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); @@ -178,102 +178,102 @@ HRClient::run(int argc, char* argv[]) do { - cout << "==> "; - cin >> command; - - if(!cin) - { - break; - } - - try - { - - // - // Common commands - // - if(command == "dept") - { - int deptno; - cin >> deptno; - if(checkCin(command)) - { - _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); - if(_currentDept != 0) - { - _currentMenu = deptMenu; - } - else - { - cout << "There is no department with deptno " << deptno << endl; - } - } - } - else if(command == "emp") - { - int empno; - cin >> empno; - if(checkCin(command)) - { - _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); - if(_currentEmp != 0) - { - _currentMenu = empMenu; - } - else - { - cout << "There is no employee with empno " << empno << endl; - } - } - } - else if(command == "exit" || command == "quit") - { - checkEof(command); - break; - } - else if(command == "help") - { - checkEof(command); - help(); - } - else if(command == "root") - { - checkEof(command); - _currentMenu = rootMenu; - } - else if(_currentMenu == rootMenu) - { - doRootMenu(command); - } - else if(_currentMenu == deptMenu) - { - doDeptMenu(command); - } - else if(_currentMenu == empMenu) - { - doEmpMenu(command); - } - else - { - assert(0); - } - } - catch(const SqlException& e) - { - cout << "Caught a SqlException: " << e.reason << endl; - } - catch(const IceUtil::Exception& e) - { - cout << "Caught an Ice exception: " << e << endl; - } - catch(const std::exception& e) - { - cout << "Caught a std::exception: " << e.what() << endl; - } - catch(...) - { - cout << "Caught an unknown exception" << endl; - } + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + try + { + + // + // Common commands + // + if(command == "dept") + { + int deptno; + cin >> deptno; + if(checkCin(command)) + { + _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); + if(_currentDept != 0) + { + _currentMenu = deptMenu; + } + else + { + cout << "There is no department with deptno " << deptno << endl; + } + } + } + else if(command == "emp") + { + int empno; + cin >> empno; + if(checkCin(command)) + { + _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); + if(_currentEmp != 0) + { + _currentMenu = empMenu; + } + else + { + cout << "There is no employee with empno " << empno << endl; + } + } + } + else if(command == "exit" || command == "quit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } } while(cin.good()); @@ -285,38 +285,38 @@ HRClient::doRootMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: deptno dname loc ==> "; - int deptno; - DeptDesc desc; - cin >> deptno >> desc.dname >> desc.loc; - - desc.dname = unquote(desc.dname); - desc.loc = unquote(desc.loc); - - if(checkCin("create parameters")) - { - _factory->createDept(deptno, desc); - cout << "Created new department number " << deptno << endl; - } + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + + desc.dname = unquote(desc.dname); + desc.loc = unquote(desc.loc); + + if(checkCin("create parameters")) + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printDepts(_factory->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printDepts(_factory->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printDepts(_factory->findAll()); + checkEof(command); + printDepts(_factory->findAll()); } else { - invalidCommand(command); + invalidCommand(command); } } @@ -325,84 +325,84 @@ HRClient::doDeptMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; - int empno; - int mgrEmpno; - EmpDesc desc; - cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; - - desc.ename = unquote(desc.ename); - desc.job = unquote(desc.job); - - if(mgrEmpno != 0) - { - desc.mgr = _factory->findEmpByNo(mgrEmpno); - if(desc.mgr == 0) - { - cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; - } - } - desc.hiredate = unquote(desc.hiredate); - desc.sal = unquote(desc.sal); - desc.comm = unquote(desc.comm); - - desc.edept = _currentDept; - - if(checkCin("create parameters")) - { - _currentDept->createEmp(empno, desc); - cout << "Created new employee number " << empno << endl; - } + checkEof(command); + cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; + int empno; + int mgrEmpno; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; + + desc.ename = unquote(desc.ename); + desc.job = unquote(desc.job); + + if(mgrEmpno != 0) + { + desc.mgr = _factory->findEmpByNo(mgrEmpno); + if(desc.mgr == 0) + { + cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; + } + } + desc.hiredate = unquote(desc.hiredate); + desc.sal = unquote(desc.sal); + desc.comm = unquote(desc.comm); + + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printEmps(_currentDept->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printEmps(_currentDept->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printEmps(_currentDept->findAll()); + checkEof(command); + printEmps(_currentDept->findAll()); } else if(command == "ping") { - checkEof(command); - _currentDept->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentDept->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentDept->remove(); + checkEof(command); + _currentDept->remove(); } else if(command == "show") { - checkEof(command); - DeptDesc desc = _currentDept->getDesc(); - cout << "deptno: " << desc.deptno << endl; - cout << "dname: " << quote(desc.dname) << endl; - cout << "loc: " << quote(desc.loc) << endl; + checkEof(command); + DeptDesc desc = _currentDept->getDesc(); + cout << "deptno: " << desc.deptno << endl; + cout << "dname: " << quote(desc.dname) << endl; + cout << "loc: " << quote(desc.loc) << endl; } else if(command == "update") { - string field; - string newValue; - cin >> field >> newValue; - newValue = unquote(newValue); - - if(checkCin("update " + field)) - { - _currentDept->updateField(field, newValue); - } + string field; + string newValue; + cin >> field >> newValue; + newValue = unquote(newValue); + + if(checkCin("update " + field)) + { + _currentDept->updateField(field, newValue); + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -411,80 +411,80 @@ HRClient::doEmpMenu(const string& command) const { if(command == "ping") { - checkEof(command); - _currentEmp->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentEmp->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentEmp->remove(); + checkEof(command); + _currentEmp->remove(); } else if(command == "show") { - checkEof(command); - EmpDesc desc = _currentEmp->getDesc(); - cout << "empno: " << desc.empno << endl; - cout << "ename: " << quote(desc.ename) << endl; - cout << "job: " << quote(desc.job) << endl; - cout << "mgr: "; - if(desc.mgr == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.mgr->getDesc().empno << endl; - } - cout << "hiredate: " << quote(desc.hiredate) << endl; - cout << "sal: " << quote(desc.sal) << endl; - cout << "comm: " << quote(desc.comm) << endl; - cout << "dept: "; - if(desc.edept == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.edept->getDesc().deptno << endl; - } + checkEof(command); + EmpDesc desc = _currentEmp->getDesc(); + cout << "empno: " << desc.empno << endl; + cout << "ename: " << quote(desc.ename) << endl; + cout << "job: " << quote(desc.job) << endl; + cout << "mgr: "; + if(desc.mgr == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.mgr->getDesc().empno << endl; + } + cout << "hiredate: " << quote(desc.hiredate) << endl; + cout << "sal: " << quote(desc.sal) << endl; + cout << "comm: " << quote(desc.comm) << endl; + cout << "dept: "; + if(desc.edept == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.edept->getDesc().deptno << endl; + } } else if(command == "update") { - string field; - cin >> field; - if(field == "mgr") - { - int mgr; - cin >> mgr; - if(checkCin("update mgr")) - { - _currentEmp->updateMgr(mgr); - } - } - else if(field == "dept") - { - int deptno; - cin >> deptno; - if(checkCin("update dept")) - { - _currentEmp->updateDept(deptno); - } - } - else - { - string newValue; - cin >> newValue; - newValue = unquote(newValue); - if(checkCin("update " + field)) - { - _currentEmp->updateField(field, newValue); - } - } + string field; + cin >> field; + if(field == "mgr") + { + int mgr; + cin >> mgr; + if(checkCin("update mgr")) + { + _currentEmp->updateMgr(mgr); + } + } + else if(field == "dept") + { + int deptno; + cin >> deptno; + if(checkCin("update dept")) + { + _currentEmp->updateDept(deptno); + } + } + else + { + string newValue; + cin >> newValue; + newValue = unquote(newValue); + if(checkCin("update " + field)) + { + _currentEmp->updateField(field, newValue); + } + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -494,15 +494,15 @@ HRClient::printDepts(const DeptPrxSeq& depts) const cout << "Deptno\t Dname\t Loc" << endl; if(depts.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) - { - HR::DeptDesc desc = (*p)->getDesc(); - cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; - } + for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) + { + HR::DeptDesc desc = (*p)->getDesc(); + cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; + } } } @@ -512,15 +512,15 @@ HRClient::printEmps(const EmpPrxSeq& emps) const cout << "Empno\t Ename" << endl; if(emps.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) - { - HR::EmpDesc desc = (*p)->getDesc(); - cout << desc.empno << "\t " << desc.ename << endl; - } + for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) + { + HR::EmpDesc desc = (*p)->getDesc(); + cout << desc.empno << "\t " << desc.ename << endl; + } } } @@ -530,11 +530,11 @@ HRClient::quote(const string& str) { if(str == "") { - return "''"; + return "''"; } else { - return str; + return str; } } @@ -544,10 +544,10 @@ HRClient::unquote(const string& str) { if(str == "''") { - return ""; + return ""; } else { - return str; + return str; } } diff --git a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp index 03a9d7538b7..336d4dc6a1b 100644 --- a/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp +++ b/cpp/demo/Database/Oracle/occi/DeptFactoryI.cpp @@ -23,7 +23,7 @@ using namespace std; using namespace oracle::occi; DeptFactoryI::DeptFactoryI(Environment* env, StatelessConnectionPool* pool, - const string& category) : + const string& category) : _env(env), _pool(pool), _category(category) @@ -58,18 +58,18 @@ DeptFactoryI::findAll(const Ice::Current& current) ConnectionHolderPtr conh = new ConnectionHolder(_pool); { - StatementHolder stmth(conh); + StatementHolder stmth(conh); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery("SELECT REF(d) FROM DEPT_VIEW d")); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(rs->getRef(1), _env); - - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); - } + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery("SELECT REF(d) FROM DEPT_VIEW d")); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(rs->getRef(1), _env); + + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + } } conh->commit(); return result; @@ -82,20 +82,20 @@ DeptFactoryI::findByName(const string& name, const Ice::Current& current) HR::DeptPrxSeq result; ConnectionHolderPtr conh = new ConnectionHolder(_pool); { - StatementHolder stmth(conh); - stmth.statement()->setSQL("SELECT REF(d) FROM DEPT_VIEW d WHERE DNAME = :1"); - stmth.statement()->setString(1, name); - - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(rs->getRef(1), _env); - - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); - } + StatementHolder stmth(conh); + stmth.statement()->setSQL("SELECT REF(d) FROM DEPT_VIEW d WHERE DNAME = :1"); + stmth.statement()->setString(1, name); + + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(rs->getRef(1), _env); + + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + } } conh->commit(); return result; @@ -111,10 +111,10 @@ DeptFactoryI::findDeptByNo(int deptno, const Ice::Current& current) if(!ref.isNull()) { - Ice::Identity deptId; - deptId.category = _category; - deptId.name = encodeRef(ref, _env); - result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.category = _category; + deptId.name = encodeRef(ref, _env); + result = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } conh->commit(); return result; @@ -129,10 +129,10 @@ DeptFactoryI::findEmpByNo(int empno, const Ice::Current& current) if(!ref.isNull()) { - Ice::Identity empId; - empId.category = _category; - empId.name = encodeRef(ref, _env); - result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId)); + Ice::Identity empId; + empId.category = _category; + empId.name = encodeRef(ref, _env); + result = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId)); } conh->commit(); return result; @@ -148,7 +148,7 @@ DeptFactoryI::findDeptRefByNo(int deptno, Connection* con) const if(rs->next() == ResultSet::END_OF_FETCH) { - return Ref<DEPT_T>(); + return Ref<DEPT_T>(); } return rs->getRef(1); } @@ -163,7 +163,7 @@ DeptFactoryI::findEmpRefByNo(int empno, Connection* con) const if(rs->next() == ResultSet::END_OF_FETCH) { - return Ref<EMP_T>(); + return Ref<EMP_T>(); } return rs->getRef(1); } diff --git a/cpp/demo/Database/Oracle/occi/DeptFactoryI.h b/cpp/demo/Database/Oracle/occi/DeptFactoryI.h index 13cf0402fc6..96ff67d28cc 100644 --- a/cpp/demo/Database/Oracle/occi/DeptFactoryI.h +++ b/cpp/demo/Database/Oracle/occi/DeptFactoryI.h @@ -19,7 +19,7 @@ class DeptFactoryI : public HR::DeptFactory public: DeptFactoryI(oracle::occi::Environment* env, oracle::occi::StatelessConnectionPool*, - const std::string&); + const std::string&); virtual HR::DeptPrx createDept(int, const HR::DeptDesc&, const Ice::Current&); @@ -34,17 +34,17 @@ public: oracle::occi::Environment* getEnv() const { - return _env; + return _env; } oracle::occi::StatelessConnectionPool* getConnectionPool() const { - return _pool; + return _pool; } const std::string& getCategory() const { - return _category; + return _category; } private: diff --git a/cpp/demo/Database/Oracle/occi/DeptI.cpp b/cpp/demo/Database/Oracle/occi/DeptI.cpp index 0703cfb9fac..d74f7ccf7cc 100644 --- a/cpp/demo/Database/Oracle/occi/DeptI.cpp +++ b/cpp/demo/Database/Oracle/occi/DeptI.cpp @@ -34,36 +34,36 @@ DeptI::createEmp(int empno, const HR::EmpDesc& desc, const Ice::Current& current // Inserted into the OCCI cache // EMP_T* emp = new(_conh->connection(), "EMP_VIEW")EMP_T; - + emp->setEmpno(empno); emp->setEname(desc.ename); emp->setJob(desc.job); if(desc.mgr != 0) { - Ref<EMP_T> mgrRef = decodeRef(desc.mgr->ice_getIdentity().name, env, _conh->connection()); - - emp->setMgrref(mgrRef); + Ref<EMP_T> mgrRef = decodeRef(desc.mgr->ice_getIdentity().name, env, _conh->connection()); + + emp->setMgrref(mgrRef); } if(desc.hiredate != "") { - Date hiredate(env); - hiredate.fromText(desc.hiredate); - emp->setHiredate(hiredate); + Date hiredate(env); + hiredate.fromText(desc.hiredate); + emp->setHiredate(hiredate); } if(desc.sal != "") { - Number sal(0); - sal.fromText(env, desc.sal, "99999.99"); - emp->setSal(sal); + Number sal(0); + sal.fromText(env, desc.sal, "99999.99"); + emp->setSal(sal); } if(desc.comm != "") { - Number comm(0); - comm.fromText(env, desc.comm, "0.999"); - emp->setComm(comm); + Number comm(0); + comm.fromText(env, desc.comm, "0.999"); + emp->setComm(comm); } emp->setDeptref(_ref); @@ -93,18 +93,18 @@ void DeptI::updateField(const string& field, const string& newValue, const Ice::Current& current) { Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - + if(field == "dname") { - deptRef->setDname(newValue); + deptRef->setDname(newValue); } else if(field == "loc") { - deptRef->setLoc(newValue); + deptRef->setLoc(newValue); } else { - throw HR::SqlException("There is no field " + field + " in object DEPT_T"); + throw HR::SqlException("There is no field " + field + " in object DEPT_T"); } deptRef->markModified(); _conh->commit(); @@ -123,21 +123,21 @@ DeptI::findAll(const Ice::Current& current) { HR::EmpPrxSeq result; { - Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); + Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - StatementHolder stmth(_conh); - stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1"); - stmth.statement()->setRef(1, deptRef); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity empId; - empId.category = _factory->getCategory(); - empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); - - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); - } + StatementHolder stmth(_conh); + stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1"); + stmth.statement()->setRef(1, deptRef); + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity empId; + empId.category = _factory->getCategory(); + empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); + + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + } } _conh->commit(); return result; @@ -148,22 +148,22 @@ DeptI::findByName(const string& name, const Ice::Current& current) { HR::EmpPrxSeq result; { - Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); + Ref<DEPT_T> deptRef = decodeRef(current.id.name, _factory->getEnv(), _conh->connection()); - StatementHolder stmth(_conh); - stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1 AND ENAME = :2"); - stmth.statement()->setRef(1, deptRef); - stmth.statement()->setString(2, name); - auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); - - while(rs->next() != ResultSet::END_OF_FETCH) - { - Ice::Identity empId; - empId.category = _factory->getCategory(); - empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); - - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); - } + StatementHolder stmth(_conh); + stmth.statement()->setSQL("SELECT REF(e) FROM EMP_VIEW e WHERE DEPTREF = :1 AND ENAME = :2"); + stmth.statement()->setRef(1, deptRef); + stmth.statement()->setString(2, name); + auto_ptr<ResultSet> rs(stmth.statement()->executeQuery()); + + while(rs->next() != ResultSet::END_OF_FETCH) + { + Ice::Identity empId; + empId.category = _factory->getCategory(); + empId.name = encodeRef(rs->getRef(1), _factory->getEnv()); + + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + } } _conh->commit(); return result; diff --git a/cpp/demo/Database/Oracle/occi/EmpI.cpp b/cpp/demo/Database/Oracle/occi/EmpI.cpp index d591542cafe..7ae0bd39461 100644 --- a/cpp/demo/Database/Oracle/occi/EmpI.cpp +++ b/cpp/demo/Database/Oracle/occi/EmpI.cpp @@ -32,31 +32,31 @@ EmpI::getDesc(const Ice::Current& current) Ref<EMP_T> mgrRef = empRef->getMgrref(); if(!mgrRef.isNull()) { - Ice::Identity mgrId; - mgrId.name = encodeRef(mgrRef, env); - mgrId.category = _factory->getCategory(); - result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); + Ice::Identity mgrId; + mgrId.name = encodeRef(mgrRef, env); + mgrId.category = _factory->getCategory(); + result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); } result.hiredate = empRef->getHiredate().toText(); if(!empRef->getSal().isNull()) { - result.sal = empRef->getSal().toText(env, "99999.99"); + result.sal = empRef->getSal().toText(env, "99999.99"); } if(!empRef->getComm().isNull()) { - result.comm = empRef->getComm().toText(env, "0.999"); + result.comm = empRef->getComm().toText(env, "0.999"); } Ref<DEPT_T> deptRef = empRef->getDeptref(); if(!deptRef.isNull()) { - Ice::Identity deptId; - deptId.name = encodeRef(deptRef, env); - deptId.category = _factory->getCategory(); - result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.name = encodeRef(deptRef, env); + deptId.category = _factory->getCategory(); + result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } _conh->commit(); return result; @@ -69,55 +69,55 @@ EmpI::updateField(const string& field, const string& newValue, const Ice::Curren if(field == "ename") { - empRef->setEname(newValue); + empRef->setEname(newValue); } else if(field == "job") { - empRef->setJob(newValue); + empRef->setJob(newValue); } else if(field == "hiredate") { - if(newValue == "") - { - empRef->setHiredate(Date()); - } - else - { - Date hiredate(_factory->getEnv()); - hiredate.fromText(newValue); - empRef->setHiredate(hiredate); - } + if(newValue == "") + { + empRef->setHiredate(Date()); + } + else + { + Date hiredate(_factory->getEnv()); + hiredate.fromText(newValue); + empRef->setHiredate(hiredate); + } } else if(field == "sal") { - if(newValue == "") - { - empRef->setSal(Number()); - } - else - { - Number sal(0); - sal.fromText(_factory->getEnv(), newValue, "99999.99"); - empRef->setSal(sal); - } + if(newValue == "") + { + empRef->setSal(Number()); + } + else + { + Number sal(0); + sal.fromText(_factory->getEnv(), newValue, "99999.99"); + empRef->setSal(sal); + } } else if(field == "comm") { - if(newValue == "") - { - empRef->setComm(Number()); - } - else - { - Number comm(0); - comm.fromText(_factory->getEnv(), newValue, "0.999"); - empRef->setComm(comm); - } + if(newValue == "") + { + empRef->setComm(Number()); + } + else + { + Number comm(0); + comm.fromText(_factory->getEnv(), newValue, "0.999"); + empRef->setComm(comm); + } } else { - throw HR::SqlException("There is no field " + field + " in type EMP_T"); - } + throw HR::SqlException("There is no field " + field + " in type EMP_T"); + } empRef->markModified(); _conh->commit(); } @@ -129,17 +129,17 @@ EmpI::updateMgr(int newMgr, const Ice::Current& current) if(newMgr == 0) { - empRef->setMgrref(Ref<EMP_T>()); + empRef->setMgrref(Ref<EMP_T>()); } else { - Ref<EMP_T> mgrRef = _factory->findEmpRefByNo(newMgr, _conh->connection()); - - if(mgrRef.isNull()) - { - throw HR::SqlException("There is no employee with this empno"); - } - empRef->setMgrref(mgrRef); + Ref<EMP_T> mgrRef = _factory->findEmpRefByNo(newMgr, _conh->connection()); + + if(mgrRef.isNull()) + { + throw HR::SqlException("There is no employee with this empno"); + } + empRef->setMgrref(mgrRef); } empRef->markModified(); _conh->commit(); @@ -152,17 +152,17 @@ EmpI::updateDept(int newDept, const Ice::Current& current) if(newDept == 0) { - empRef->setDeptref(Ref<DEPT_T>()); + empRef->setDeptref(Ref<DEPT_T>()); } else { - Ref<DEPT_T> deptRef = _factory->findDeptRefByNo(newDept, _conh->connection()); - - if(deptRef.isNull()) - { - throw HR::SqlException("There is no department with this deptno"); - } - empRef->setDeptref(deptRef); + Ref<DEPT_T> deptRef = _factory->findDeptRefByNo(newDept, _conh->connection()); + + if(deptRef.isNull()) + { + throw HR::SqlException("There is no department with this deptno"); + } + empRef->setDeptref(deptRef); } empRef->markModified(); _conh->commit(); diff --git a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp index 4236c9dc542..6d8b0ba8449 100755 --- a/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp +++ b/cpp/demo/Database/Oracle/occi/OCCIServantLocator.cpp @@ -30,37 +30,37 @@ OCCIServantLocator::locate(const Ice::Current& current, Ice::LocalObjectPtr& coo try
{
- //
- // Extract SQL type from target object
- //
- string sqlType = Ref<PObject>(ref)->getSQLTypeName();
+ //
+ // Extract SQL type from target object
+ //
+ string sqlType = Ref<PObject>(ref)->getSQLTypeName();
- //
- // Create and return the servant, used only for this one operation
- //
- if(sqlType.find("EMP_T") != string::npos)
- {
- return new EmpI(ref, con, _factory);
- }
- else if(sqlType.find("DEPT_T") != string::npos)
- {
- return new DeptI(ref, con, _factory);
- }
- else
- {
- return 0;
- }
+ //
+ // Create and return the servant, used only for this one operation
+ //
+ if(sqlType.find("EMP_T") != string::npos)
+ {
+ return new EmpI(ref, con, _factory);
+ }
+ else if(sqlType.find("DEPT_T") != string::npos)
+ {
+ return new DeptI(ref, con, _factory);
+ }
+ else
+ {
+ return 0;
+ }
}
catch(const SQLException& sqle)
{
- if(sqle.getErrorCode() == 21700)
- {
- return 0;
- }
- else
- {
- throw;
- }
+ if(sqle.getErrorCode() == 21700)
+ {
+ return 0;
+ }
+ else
+ {
+ throw;
+ }
}
}
diff --git a/cpp/demo/Database/Oracle/occi/Server.cpp b/cpp/demo/Database/Oracle/occi/Server.cpp index aff2f171ea3..8df9dceb43f 100644 --- a/cpp/demo/Database/Oracle/occi/Server.cpp +++ b/cpp/demo/Database/Oracle/occi/Server.cpp @@ -47,42 +47,42 @@ HRServer::run(int argc, char* argv[]) try { - env = Environment::createEnvironment(Environment::Mode(Environment::THREADED_MUTEXED | Environment::OBJECT)); - DbTypesMap(env); - - pool = env->createStatelessConnectionPool(username, password, connectString, 5, 2, 1, - StatelessConnectionPool::HOMOGENEOUS); + env = Environment::createEnvironment(Environment::Mode(Environment::THREADED_MUTEXED | Environment::OBJECT)); + DbTypesMap(env); + + pool = env->createStatelessConnectionPool(username, password, connectString, 5, 2, 1, + StatelessConnectionPool::HOMOGENEOUS); - Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR"); - - DeptFactoryIPtr factory = new DeptFactoryI(env, pool, category); - adapter->addServantLocator(new OCCIServantLocator(factory), category); + Ice::ObjectAdapterPtr adapter = communicator()->createObjectAdapter("HR"); + + DeptFactoryIPtr factory = new DeptFactoryI(env, pool, category); + adapter->addServantLocator(new OCCIServantLocator(factory), category); - adapter->add(factory, communicator()->stringToIdentity("DeptFactory")); - - adapter->activate(); - communicator()->waitForShutdown(); + adapter->add(factory, communicator()->stringToIdentity("DeptFactory")); + + adapter->activate(); + communicator()->waitForShutdown(); } catch(...) { - if(pool != 0) - { - env->terminateStatelessConnectionPool(pool); - } - if(env != 0) - { - Environment::terminateEnvironment(env); - } - throw; + if(pool != 0) + { + env->terminateStatelessConnectionPool(pool); + } + if(env != 0) + { + Environment::terminateEnvironment(env); + } + throw; } if(pool != 0) { - env->terminateStatelessConnectionPool(pool); + env->terminateStatelessConnectionPool(pool); } if(env != 0) { - Environment::terminateEnvironment(env); + Environment::terminateEnvironment(env); } return EXIT_SUCCESS; } diff --git a/cpp/demo/Database/Oracle/occi/Util.cpp b/cpp/demo/Database/Oracle/occi/Util.cpp index 44c6dda8912..7b6a109e494 100644 --- a/cpp/demo/Database/Oracle/occi/Util.cpp +++ b/cpp/demo/Database/Oracle/occi/Util.cpp @@ -28,11 +28,11 @@ ConnectionHolder::commit() _txDone = true; try { - _con->commit(); + _con->commit(); } catch(const SQLException& e) { - throw HR::SqlException(e.what()); + throw HR::SqlException(e.what()); } } @@ -42,11 +42,11 @@ ConnectionHolder::rollback() _txDone = true; try { - _con->rollback(); + _con->rollback(); } catch(const SQLException& e) { - throw HR::SqlException(e.what()); + throw HR::SqlException(e.what()); } } @@ -54,19 +54,19 @@ ConnectionHolder::~ConnectionHolder() { if(!_txDone) { - _txDone = true; - try - { - _con->rollback(); - } - catch(const std::exception&) - { - } + _txDone = true; + try + { + _con->rollback(); + } + catch(const std::exception&) + { + } } try { - _pool->releaseConnection(_con); + _pool->releaseConnection(_con); } catch(const std::exception&) { @@ -104,15 +104,15 @@ encodeRef(const RefAny& ref, Environment* env) if(status == OCI_SUCCESS) { - result.assign(reinterpret_cast<char*>(buffer), length); + result.assign(reinterpret_cast<char*>(buffer), length); } else { - cerr << "encodeRef failed: "; - sb4 errcode = 0; - OraText buf[512]; - OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); - cerr << reinterpret_cast<char*>(buf) << endl; + cerr << "encodeRef failed: "; + sb4 errcode = 0; + OraText buf[512]; + OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); + cerr << reinterpret_cast<char*>(buf) << endl; } OCIHandleFree(error, OCI_HTYPE_ERROR); @@ -128,26 +128,26 @@ decodeRef(const string& str, Environment* env, Connection* con) OCIHandleAlloc(env->getOCIEnvironment(), reinterpret_cast<void**>(&error), OCI_HTYPE_ERROR, 0, 0); sword status = OCIRefFromHex(env->getOCIEnvironment(), error, - con->getOCIServiceContext(), - reinterpret_cast<const OraText*>(str.c_str()), str.length(), - &ref); + con->getOCIServiceContext(), + reinterpret_cast<const OraText*>(str.c_str()), str.length(), + &ref); if(status == OCI_SUCCESS) - { - OCIHandleFree(error, OCI_HTYPE_ERROR); - return RefAny(con, ref); + { + OCIHandleFree(error, OCI_HTYPE_ERROR); + return RefAny(con, ref); } else { - cerr << "decodeRef failed: "; - sb4 errcode = 0; - OraText buf[512]; - OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); - cerr << reinterpret_cast<char*>(buf) << endl; - - OCIHandleFree(error, OCI_HTYPE_ERROR); - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + cerr << "decodeRef failed: "; + sb4 errcode = 0; + OraText buf[512]; + OCIErrorGet(error, 1, 0, &errcode, buf, 512, OCI_HTYPE_ERROR); + cerr << reinterpret_cast<char*>(buf) << endl; + + OCIHandleFree(error, OCI_HTYPE_ERROR); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } diff --git a/cpp/demo/Database/Oracle/occi/Util.h b/cpp/demo/Database/Oracle/occi/Util.h index dbe44d6b9c3..2655b2281ec 100644 --- a/cpp/demo/Database/Oracle/occi/Util.h +++ b/cpp/demo/Database/Oracle/occi/Util.h @@ -25,7 +25,7 @@ public: oracle::occi::Connection* connection() const { - return _con; + return _con; } void commit(); @@ -55,7 +55,7 @@ public: oracle::occi::Statement* statement() const { - return _stmt; + return _stmt; } private: diff --git a/cpp/demo/Database/Oracle/proc/Client.cpp b/cpp/demo/Database/Oracle/proc/Client.cpp index 2260decdd0b..569fdf620fc 100644 --- a/cpp/demo/Database/Oracle/proc/Client.cpp +++ b/cpp/demo/Database/Oracle/proc/Client.cpp @@ -63,32 +63,32 @@ HRClient::HRClient() : _currentMenu(rootMenu) { _commonCommands = - "dept <number>: set department <number> as the current department\n" - "emp <number>: set employee <number> as the current employee\n" - "exit or quit: exit client\n" - "help: print this list of commands\n" - "root: go back to the root menu\n"; + "dept <number>: set department <number> as the current department\n" + "emp <number>: set employee <number> as the current employee\n" + "exit or quit: exit client\n" + "help: print this list of commands\n" + "root: go back to the root menu\n"; _rootCommands = - "create: create a new department\n" - "find <name>: find the department(s) with the given name\n" - "list: list all departments\n"; + "create: create a new department\n" + "find <name>: find the department(s) with the given name\n" + "list: list all departments\n"; - + _deptCommands = - "create: create a new employee in this department\n" - "find <name>: find employee(s) named <name> in this department\n" - "list: list all employees in this department\n" - "ping: ping this department\n" - "remove: remove this department\n" - "show: describe this department\n" - "update <dname|loc> <new value>: update this department\n"; + "create: create a new employee in this department\n" + "find <name>: find employee(s) named <name> in this department\n" + "list: list all employees in this department\n" + "ping: ping this department\n" + "remove: remove this department\n" + "show: describe this department\n" + "update <dname|loc> <new value>: update this department\n"; _empCommands = - "ping: ping this employee\n" - "remove: remove this employee\n" - "show: describe this employee\n" - "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; + "ping: ping this employee\n" + "remove: remove this employee\n" + "show: describe this employee\n" + "update <ename|job|mgr|hiredate|sal|comm|dept> <new-value>: update this employee\n"; } void @@ -96,13 +96,13 @@ HRClient::checkEof(const string& command) const { if(!cin.eof()) { - string extra; - getline(cin, extra); - if(extra.size() > 0) - { - cout << "Warning: ignoring extra args '" << extra - << "' for '" << command << "'" << endl; - } + string extra; + getline(cin, extra); + if(extra.size() > 0) + { + cout << "Warning: ignoring extra args '" << extra + << "' for '" << command << "'" << endl; + } } } @@ -111,10 +111,10 @@ HRClient::checkCin(const string& command) const { if(!cin) { - cout << "Error: failed to read arguments for '" << command << "'" << endl; - cin.clear(); - cin.ignore(numeric_limits<streamsize>::max(), '\n'); - return false; + cout << "Error: failed to read arguments for '" << command << "'" << endl; + cin.clear(); + cin.ignore(numeric_limits<streamsize>::max(), '\n'); + return false; } checkEof(command); return true; @@ -124,7 +124,7 @@ void HRClient::invalidCommand(const string& command) const { cout << "Invalid command '" << command << "'. " - "Type 'help' for help." << endl; + "Type 'help' for help." << endl; cin.ignore(numeric_limits<streamsize>::max(), '\n'); } @@ -136,21 +136,21 @@ HRClient::help() const switch(_currentMenu) { - case rootMenu: - { - cout << _rootCommands; - break; - } - case deptMenu: - { - cout << _deptCommands; - break; - } - case empMenu: - { - cout << _empCommands; - break; - } + case rootMenu: + { + cout << _rootCommands; + break; + } + case deptMenu: + { + cout << _deptCommands; + break; + } + case empMenu: + { + cout << _empCommands; + break; + } } cout << "--- Common to all menus ---\n"; cout << _commonCommands << endl; @@ -163,8 +163,8 @@ HRClient::run(int argc, char* argv[]) _factory = DeptFactoryPrx::checkedCast(base); if(_factory == 0) { - cerr << argv[0] << ": invalid proxy" << endl; - return EXIT_FAILURE; + cerr << argv[0] << ": invalid proxy" << endl; + return EXIT_FAILURE; } Ice::EndpointSeq endpoints = _factory->ice_getEndpoints(); @@ -178,102 +178,102 @@ HRClient::run(int argc, char* argv[]) do { - cout << "==> "; - cin >> command; - - if(!cin) - { - break; - } - - try - { - - // - // Common commands - // - if(command == "dept") - { - int deptno; - cin >> deptno; - if(checkCin(command)) - { - _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); - if(_currentDept != 0) - { - _currentMenu = deptMenu; - } - else - { - cout << "There is no department with deptno " << deptno << endl; - } - } - } - else if(command == "emp") - { - int empno; - cin >> empno; - if(checkCin(command)) - { - _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); - if(_currentEmp != 0) - { - _currentMenu = empMenu; - } - else - { - cout << "There is no employee with empno " << empno << endl; - } - } - } - else if(command == "exit" || command == "quit") - { - checkEof(command); - break; - } - else if(command == "help") - { - checkEof(command); - help(); - } - else if(command == "root") - { - checkEof(command); - _currentMenu = rootMenu; - } - else if(_currentMenu == rootMenu) - { - doRootMenu(command); - } - else if(_currentMenu == deptMenu) - { - doDeptMenu(command); - } - else if(_currentMenu == empMenu) - { - doEmpMenu(command); - } - else - { - assert(0); - } - } - catch(const SqlException& e) - { - cout << "Caught a SqlException: " << e.reason << endl; - } - catch(const IceUtil::Exception& e) - { - cout << "Caught an Ice exception: " << e << endl; - } - catch(const std::exception& e) - { - cout << "Caught a std::exception: " << e.what() << endl; - } - catch(...) - { - cout << "Caught an unknown exception" << endl; - } + cout << "==> "; + cin >> command; + + if(!cin) + { + break; + } + + try + { + + // + // Common commands + // + if(command == "dept") + { + int deptno; + cin >> deptno; + if(checkCin(command)) + { + _currentDept = DeptPrx::uncheckedCast(_factory->findDeptByNo(deptno)); + if(_currentDept != 0) + { + _currentMenu = deptMenu; + } + else + { + cout << "There is no department with deptno " << deptno << endl; + } + } + } + else if(command == "emp") + { + int empno; + cin >> empno; + if(checkCin(command)) + { + _currentEmp = EmpPrx::uncheckedCast(_factory->findEmpByNo(empno)); + if(_currentEmp != 0) + { + _currentMenu = empMenu; + } + else + { + cout << "There is no employee with empno " << empno << endl; + } + } + } + else if(command == "exit" || command == "quit") + { + checkEof(command); + break; + } + else if(command == "help") + { + checkEof(command); + help(); + } + else if(command == "root") + { + checkEof(command); + _currentMenu = rootMenu; + } + else if(_currentMenu == rootMenu) + { + doRootMenu(command); + } + else if(_currentMenu == deptMenu) + { + doDeptMenu(command); + } + else if(_currentMenu == empMenu) + { + doEmpMenu(command); + } + else + { + assert(0); + } + } + catch(const SqlException& e) + { + cout << "Caught a SqlException: " << e.reason << endl; + } + catch(const IceUtil::Exception& e) + { + cout << "Caught an Ice exception: " << e << endl; + } + catch(const std::exception& e) + { + cout << "Caught a std::exception: " << e.what() << endl; + } + catch(...) + { + cout << "Caught an unknown exception" << endl; + } } while(cin.good()); @@ -285,38 +285,38 @@ HRClient::doRootMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: deptno dname loc ==> "; - int deptno; - DeptDesc desc; - cin >> deptno >> desc.dname >> desc.loc; - - desc.dname = unquote(desc.dname); - desc.loc = unquote(desc.loc); - - if(checkCin("create parameters")) - { - _factory->createDept(deptno, desc); - cout << "Created new department number " << deptno << endl; - } + checkEof(command); + cout << "Please enter: deptno dname loc ==> "; + int deptno; + DeptDesc desc; + cin >> deptno >> desc.dname >> desc.loc; + + desc.dname = unquote(desc.dname); + desc.loc = unquote(desc.loc); + + if(checkCin("create parameters")) + { + _factory->createDept(deptno, desc); + cout << "Created new department number " << deptno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printDepts(_factory->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printDepts(_factory->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printDepts(_factory->findAll()); + checkEof(command); + printDepts(_factory->findAll()); } else { - invalidCommand(command); + invalidCommand(command); } } @@ -325,84 +325,84 @@ HRClient::doDeptMenu(const string& command) const { if(command == "create") { - checkEof(command); - cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; - int empno; - int mgrEmpno; - EmpDesc desc; - cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; - - desc.ename = unquote(desc.ename); - desc.job = unquote(desc.job); - - if(mgrEmpno != 0) - { - desc.mgr = _factory->findEmpByNo(mgrEmpno); - if(desc.mgr == 0) - { - cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; - } - } - desc.hiredate = unquote(desc.hiredate); - desc.sal = unquote(desc.sal); - desc.comm = unquote(desc.comm); - - desc.edept = _currentDept; - - if(checkCin("create parameters")) - { - _currentDept->createEmp(empno, desc); - cout << "Created new employee number " << empno << endl; - } + checkEof(command); + cout << "Please enter: empno ename job mgr(empno) hiredate sal comm ==> "; + int empno; + int mgrEmpno; + EmpDesc desc; + cin >> empno >> desc.ename >> desc.job >> mgrEmpno >> desc.hiredate >> desc.sal >> desc.comm; + + desc.ename = unquote(desc.ename); + desc.job = unquote(desc.job); + + if(mgrEmpno != 0) + { + desc.mgr = _factory->findEmpByNo(mgrEmpno); + if(desc.mgr == 0) + { + cout << "Manager #" << mgrEmpno << " does not exist: clearing manager" << endl; + } + } + desc.hiredate = unquote(desc.hiredate); + desc.sal = unquote(desc.sal); + desc.comm = unquote(desc.comm); + + desc.edept = _currentDept; + + if(checkCin("create parameters")) + { + _currentDept->createEmp(empno, desc); + cout << "Created new employee number " << empno << endl; + } } else if(command == "find") { - string name; - cin >> name; - if(checkCin(command)) - { - printEmps(_currentDept->findByName(name)); - } + string name; + cin >> name; + if(checkCin(command)) + { + printEmps(_currentDept->findByName(name)); + } } else if(command == "list") { - checkEof(command); - printEmps(_currentDept->findAll()); + checkEof(command); + printEmps(_currentDept->findAll()); } else if(command == "ping") { - checkEof(command); - _currentDept->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentDept->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentDept->remove(); + checkEof(command); + _currentDept->remove(); } else if(command == "show") { - checkEof(command); - DeptDesc desc = _currentDept->getDesc(); - cout << "deptno: " << desc.deptno << endl; - cout << "dname: " << quote(desc.dname) << endl; - cout << "loc: " << quote(desc.loc) << endl; + checkEof(command); + DeptDesc desc = _currentDept->getDesc(); + cout << "deptno: " << desc.deptno << endl; + cout << "dname: " << quote(desc.dname) << endl; + cout << "loc: " << quote(desc.loc) << endl; } else if(command == "update") { - string field; - string newValue; - cin >> field >> newValue; - newValue = unquote(newValue); - - if(checkCin("update " + field)) - { - _currentDept->updateField(field, newValue); - } + string field; + string newValue; + cin >> field >> newValue; + newValue = unquote(newValue); + + if(checkCin("update " + field)) + { + _currentDept->updateField(field, newValue); + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -411,80 +411,80 @@ HRClient::doEmpMenu(const string& command) const { if(command == "ping") { - checkEof(command); - _currentEmp->ice_ping(); - cout << "ice_ping: success!" << endl; + checkEof(command); + _currentEmp->ice_ping(); + cout << "ice_ping: success!" << endl; } else if(command == "remove") { - checkEof(command); - _currentEmp->remove(); + checkEof(command); + _currentEmp->remove(); } else if(command == "show") { - checkEof(command); - EmpDesc desc = _currentEmp->getDesc(); - cout << "empno: " << desc.empno << endl; - cout << "ename: " << quote(desc.ename) << endl; - cout << "job: " << quote(desc.job) << endl; - cout << "mgr: "; - if(desc.mgr == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.mgr->getDesc().empno << endl; - } - cout << "hiredate: " << quote(desc.hiredate) << endl; - cout << "sal: " << quote(desc.sal) << endl; - cout << "comm: " << quote(desc.comm) << endl; - cout << "dept: "; - if(desc.edept == 0) - { - cout << "<null>" << endl; - } - else - { - cout << desc.edept->getDesc().deptno << endl; - } + checkEof(command); + EmpDesc desc = _currentEmp->getDesc(); + cout << "empno: " << desc.empno << endl; + cout << "ename: " << quote(desc.ename) << endl; + cout << "job: " << quote(desc.job) << endl; + cout << "mgr: "; + if(desc.mgr == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.mgr->getDesc().empno << endl; + } + cout << "hiredate: " << quote(desc.hiredate) << endl; + cout << "sal: " << quote(desc.sal) << endl; + cout << "comm: " << quote(desc.comm) << endl; + cout << "dept: "; + if(desc.edept == 0) + { + cout << "<null>" << endl; + } + else + { + cout << desc.edept->getDesc().deptno << endl; + } } else if(command == "update") { - string field; - cin >> field; - if(field == "mgr") - { - int mgr; - cin >> mgr; - if(checkCin("update mgr")) - { - _currentEmp->updateMgr(mgr); - } - } - else if(field == "dept") - { - int deptno; - cin >> deptno; - if(checkCin("update dept")) - { - _currentEmp->updateDept(deptno); - } - } - else - { - string newValue; - cin >> newValue; - newValue = unquote(newValue); - if(checkCin("update " + field)) - { - _currentEmp->updateField(field, newValue); - } - } + string field; + cin >> field; + if(field == "mgr") + { + int mgr; + cin >> mgr; + if(checkCin("update mgr")) + { + _currentEmp->updateMgr(mgr); + } + } + else if(field == "dept") + { + int deptno; + cin >> deptno; + if(checkCin("update dept")) + { + _currentEmp->updateDept(deptno); + } + } + else + { + string newValue; + cin >> newValue; + newValue = unquote(newValue); + if(checkCin("update " + field)) + { + _currentEmp->updateField(field, newValue); + } + } } else { - invalidCommand(command); + invalidCommand(command); } } @@ -494,15 +494,15 @@ HRClient::printDepts(const DeptPrxSeq& depts) const cout << "Deptno\t Dname\t Loc" << endl; if(depts.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) - { - HR::DeptDesc desc = (*p)->getDesc(); - cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; - } + for(DeptPrxSeq::const_iterator p = depts.begin(); p != depts.end(); ++p) + { + HR::DeptDesc desc = (*p)->getDesc(); + cout << desc.deptno << "\t " << desc.dname << "\t " << desc.loc << endl; + } } } @@ -512,15 +512,15 @@ HRClient::printEmps(const EmpPrxSeq& emps) const cout << "Empno\t Ename" << endl; if(emps.size() == 0) { - cout << "<None found>" << endl; + cout << "<None found>" << endl; } else { - for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) - { - HR::EmpDesc desc = (*p)->getDesc(); - cout << desc.empno << "\t " << desc.ename << endl; - } + for(EmpPrxSeq::const_iterator p = emps.begin(); p != emps.end(); ++p) + { + HR::EmpDesc desc = (*p)->getDesc(); + cout << desc.empno << "\t " << desc.ename << endl; + } } } @@ -530,11 +530,11 @@ HRClient::quote(const string& str) { if(str == "") { - return "''"; + return "''"; } else { - return str; + return str; } } @@ -544,10 +544,10 @@ HRClient::unquote(const string& str) { if(str == "''") { - return ""; + return ""; } else { - return str; + return str; } } diff --git a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc index 862196b8718..35e27fc3749 100644 --- a/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc +++ b/cpp/demo/Database/Oracle/proc/CurrentSqlContext.pc @@ -38,7 +38,7 @@ class Notification : public Ice::ThreadNotification public: Notification(size_t index) : - _index(index) + _index(index) { } @@ -48,35 +48,35 @@ public: virtual void stop() { - if(_current != 0 && _index < _current->size()) - { + if(_current != 0 && _index < _current->size()) + { #ifdef TRACE - cerr << "Disconnecting from Oracle in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Disconnecting from Oracle in thread " << IceUtil::ThreadControl().id() << endl; #endif - EXEC SQL BEGIN DECLARE SECTION; - sql_context ctx = (*_current)[_index]; - EXEC SQL END DECLARE SECTION; - - if(ctx != 0) - { - (*_current)[_index] = 0; - EXEC SQL CONTEXT USE :ctx; - - sqlca sqlca; - EXEC SQL ROLLBACK RELEASE; - EXEC SQL CONTEXT FREE :ctx; - } - - if(find_if(_current->begin(), _current->end(), bind2nd(not_equal_to<sql_context>(), static_cast<void*>(0))) - == _current->end()) - { + EXEC SQL BEGIN DECLARE SECTION; + sql_context ctx = (*_current)[_index]; + EXEC SQL END DECLARE SECTION; + + if(ctx != 0) + { + (*_current)[_index] = 0; + EXEC SQL CONTEXT USE :ctx; + + sqlca sqlca; + EXEC SQL ROLLBACK RELEASE; + EXEC SQL CONTEXT FREE :ctx; + } + + if(find_if(_current->begin(), _current->end(), bind2nd(not_equal_to<sql_context>(), static_cast<void*>(0))) + == _current->end()) + { #ifdef TRACE - cerr << "Deleting _current in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Deleting _current in thread " << IceUtil::ThreadControl().id() << endl; #endif - delete _current; - _current = 0; - } - } + delete _current; + _current = 0; + } + } } private: @@ -90,8 +90,8 @@ CurrentSqlContext::CurrentSqlContext(const string& connectInfo) : _connectInfo(connectInfo) { { - IceUtil::StaticMutex::Lock lock(IceUtil::globalMutex); - _index = _currentIndex++; + IceUtil::StaticMutex::Lock lock(IceUtil::globalMutex); + _index = _currentIndex++; } _hook = new Notification(_index); } @@ -106,11 +106,11 @@ CurrentSqlContext::operator sql_context() const { if(_current == 0) { - _current = new std::vector<sql_context>(_index + 1); + _current = new std::vector<sql_context>(_index + 1); } if(_index >= _current->size()) { - _current->resize(_index + 1); + _current->resize(_index + 1); } EXEC SQL BEGIN DECLARE SECTION; @@ -123,18 +123,18 @@ CurrentSqlContext::operator sql_context() const if(ctx == 0) { #ifdef TRACE - cerr << "Connecting to Oracle in thread " << IceUtil::ThreadControl().id() << endl; + cerr << "Connecting to Oracle in thread " << IceUtil::ThreadControl().id() << endl; #endif - // - // Allocate and connect - // - sqlca sqlca; - - EXEC SQL CONTEXT ALLOCATE :ctx; - EXEC SQL CONTEXT USE :ctx; - EXEC SQL CONNECT :connectInfo; - - (*_current)[_index] = ctx; + // + // Allocate and connect + // + sqlca sqlca; + + EXEC SQL CONTEXT ALLOCATE :ctx; + EXEC SQL CONTEXT USE :ctx; + EXEC SQL CONNECT :connectInfo; + + (*_current)[_index] = ctx; } return ctx; diff --git a/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc index 1d72b58d0db..e6bcdd56145 100644 --- a/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc +++ b/cpp/demo/Database/Oracle/proc/DeptFactoryI.pc @@ -62,13 +62,13 @@ DeptFactoryI::findAll(const Ice::Current& current) for(;;) { - EXEC SQL FETCH depCursor1 INTO :deptno; + EXEC SQL FETCH depCursor1 INTO :deptno; - Ice::Identity deptId; - deptId.category = _deptCategory; - deptId.name = encodeName(deptno); + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); } EXEC SQL CLOSE depCursor1; @@ -94,13 +94,13 @@ DeptFactoryI::findByName(const string& name, const Ice::Current& current) for(;;) { - EXEC SQL FETCH depCursor2 INTO :deptno; + EXEC SQL FETCH depCursor2 INTO :deptno; - Ice::Identity deptId; - deptId.category = _deptCategory; - deptId.name = encodeName(deptno); + Ice::Identity deptId; + deptId.category = _deptCategory; + deptId.name = encodeName(deptno); - result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); + result.push_back(HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId))); } EXEC SQL CLOSE depCursor2; @@ -121,11 +121,11 @@ DeptFactoryI::findDeptByNo(int deptno, const Ice::Current& current) // try { - prx->ice_ping(); + prx->ice_ping(); } catch(const Ice::ObjectNotExistException&) { - return 0; + return 0; } return HR::DeptPrx::uncheckedCast(prx); @@ -144,11 +144,11 @@ DeptFactoryI::findEmpByNo(int empno, const Ice::Current& current) // try { - prx->ice_ping(); + prx->ice_ping(); } catch(const Ice::ObjectNotExistException&) { - return 0; + return 0; } return HR::EmpPrx::uncheckedCast(prx); diff --git a/cpp/demo/Database/Oracle/proc/DeptI.pc b/cpp/demo/Database/Oracle/proc/DeptI.pc index 7a9d2c63f1c..203ab110a5a 100644 --- a/cpp/demo/Database/Oracle/proc/DeptI.pc +++ b/cpp/demo/Database/Oracle/proc/DeptI.pc @@ -38,7 +38,7 @@ DeptI::ice_ping(const Ice::Current& current) const if(count == 0) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -64,19 +64,19 @@ DeptI::createEmp(int key, const HR::EmpDesc& desc, const Ice::Current& current) if(desc.mgr == 0) { - // - // mgr is NULL - // - mgrInd = -1; + // + // mgr is NULL + // + mgrInd = -1; } else { - mgr = decodeName(desc.mgr->ice_getIdentity().name); + mgr = decodeName(desc.mgr->ice_getIdentity().name); } EXEC SQL CONTEXT USE :ctx; EXEC SQL INSERT INTO EMP(empno, ename, job, mgr, hiredate, sal, comm, deptno) - VALUES(:empno, :ename, :job, :mgr:mgrInd, :hiredate, :sal, :comm, :deptno); + VALUES(:empno, :ename, :job, :mgr:mgrInd, :hiredate, :sal, :comm, :deptno); EXEC SQL COMMIT; Ice::Identity empId; @@ -107,10 +107,10 @@ DeptI::getDesc(const Ice::Current& current) if(dnameInd >= 0) { - // - // Should log a warning if > 0! - // - result.dname = dname; + // + // Should log a warning if > 0! + // + result.dname = dname; } // // else null @@ -118,10 +118,10 @@ DeptI::getDesc(const Ice::Current& current) if(locInd >= 0) { - // - // Should log a warning if > 0! - // - result.loc = loc; + // + // Should log a warning if > 0! + // + result.loc = loc; } // // else null @@ -134,7 +134,7 @@ void DeptI::updateField(const string& field, const string& newValue, const Ice::Current& current) { const string updateDeptStr = - "UPDATE DEPT SET " + field + " = '" + newValue + "' WHERE DEPTNO = " + current.id.name; + "UPDATE DEPT SET " + field + " = '" + newValue + "' WHERE DEPTNO = " + current.id.name; sqlca sqlca; EXEC SQL BEGIN DECLARE SECTION; @@ -185,13 +185,13 @@ DeptI::findAll(const Ice::Current& current) for(;;) { - EXEC SQL FETCH empCursor1 INTO :empno; + EXEC SQL FETCH empCursor1 INTO :empno; - Ice::Identity empId; - empId.category = _empCategory; - empId.name = encodeName(empno); + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); } EXEC SQL CLOSE empCursor1; @@ -218,13 +218,13 @@ DeptI::findByName(const string& name, const Ice::Current& current) for(;;) { - EXEC SQL FETCH empCursor2 INTO :empno; + EXEC SQL FETCH empCursor2 INTO :empno; - Ice::Identity empId; - empId.category = _empCategory; - empId.name = encodeName(empno); + Ice::Identity empId; + empId.category = _empCategory; + empId.name = encodeName(empno); - result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); + result.push_back(HR::EmpPrx::uncheckedCast(current.adapter->createProxy(empId))); } EXEC SQL CLOSE empCursor2; diff --git a/cpp/demo/Database/Oracle/proc/EmpI.pc b/cpp/demo/Database/Oracle/proc/EmpI.pc index e74887a939d..5506d0d0d84 100644 --- a/cpp/demo/Database/Oracle/proc/EmpI.pc +++ b/cpp/demo/Database/Oracle/proc/EmpI.pc @@ -17,7 +17,7 @@ EXEC SQL WHENEVER NOT FOUND DO handleNotFound(current, ctx); using namespace std; EmpI::EmpI(const CurrentSqlContext& currentCtx, - const string& empCategory, const string& deptCategory) : + const string& empCategory, const string& deptCategory) : _currentCtx(currentCtx), _empCategory(empCategory), _deptCategory(deptCategory) @@ -40,7 +40,7 @@ EmpI::ice_ping(const Ice::Current& current) const if(count == 0) { - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } } @@ -69,7 +69,7 @@ EmpI::getDesc(const Ice::Current& current) EXEC SQL CONTEXT USE :ctx; EXEC SQL SELECT ENAME, JOB, MGR, HIREDATE, SAL, COMM, DEPTNO - INTO :ename:enameInd, :job:jobInd, :mgr:mgrInd, :hiredate:hiredateInd, :sal:salInd, :comm:commInd, + INTO :ename:enameInd, :job:jobInd, :mgr:mgrInd, :hiredate:hiredateInd, :sal:salInd, :comm:commInd, :deptno:deptnoInd FROM EMP WHERE EMPNO = :empno; EXEC SQL COMMIT; @@ -79,37 +79,37 @@ EmpI::getDesc(const Ice::Current& current) if(enameInd >= 0) { - result.ename = ename; + result.ename = ename; } if(jobInd >= 0) { - result.job = job; + result.job = job; } if(mgrInd >= 0) { - Ice::Identity mgrId; - mgrId.name = encodeName(mgr); - mgrId.category = _empCategory; - result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); + Ice::Identity mgrId; + mgrId.name = encodeName(mgr); + mgrId.category = _empCategory; + result.mgr = HR::EmpPrx::uncheckedCast(current.adapter->createProxy(mgrId)); } if(hiredateInd >= 0) { - result.hiredate = hiredate; + result.hiredate = hiredate; } if(salInd >= 0) { - result.sal = sal; + result.sal = sal; } if(commInd >= 0) { - result.comm = comm; + result.comm = comm; } if(deptnoInd >= 0) { - Ice::Identity deptId; - deptId.name = encodeName(deptno); - deptId.category = _deptCategory; - result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); + Ice::Identity deptId; + deptId.name = encodeName(deptno); + deptId.category = _deptCategory; + result.edept = HR::DeptPrx::uncheckedCast(current.adapter->createProxy(deptId)); } return result; } @@ -118,7 +118,7 @@ void EmpI::updateField(const string& field, const string& newValue, const Ice::Current& current) { const string updateEmpStr = - "UPDATE EMP SET " + field + " = '" + newValue + "' WHERE EMPNO = " + current.id.name; + "UPDATE EMP SET " + field + " = '" + newValue + "' WHERE EMPNO = " + current.id.name; sqlca sqlca; EXEC SQL BEGIN DECLARE SECTION; diff --git a/cpp/demo/Database/Oracle/proc/Server.pc b/cpp/demo/Database/Oracle/proc/Server.pc index a0a0d80e083..bc325649259 100644 --- a/cpp/demo/Database/Oracle/proc/Server.pc +++ b/cpp/demo/Database/Oracle/proc/Server.pc @@ -34,18 +34,18 @@ class DefaultServantLocator : public Ice::ServantLocator public: DefaultServantLocator(const Ice::ObjectPtr& servant) : - _servant(servant) + _servant(servant) { } virtual Ice::ObjectPtr locate(const Ice::Current&, Ice::LocalObjectPtr&) { - return _servant; + return _servant; } virtual void finished(const Ice::Current& curr, - const Ice::ObjectPtr& servant, - const Ice::LocalObjectPtr& cookie) + const Ice::ObjectPtr& servant, + const Ice::LocalObjectPtr& cookie) { } @@ -70,7 +70,7 @@ main(int argc, char* argv[]) initData.properties->load("config.server"); const string connectInfo = initData.properties - ->getPropertyWithDefault("Oracle.ConnectInfo", "scott/tiger"); + ->getPropertyWithDefault("Oracle.ConnectInfo", "scott/tiger"); CurrentSqlContext currentCtx(connectInfo); initData.threadHook = currentCtx.getHook(); @@ -92,12 +92,12 @@ HRServer::run(int argc, char* argv[]) const string deptCategory = "Dept"; adapter->addServantLocator(new DefaultServantLocator(new EmpI(_currentCtx, empCategory, deptCategory)), - empCategory); + empCategory); adapter->addServantLocator(new DefaultServantLocator(new DeptI(_currentCtx, empCategory)), deptCategory); adapter->add(new DeptFactoryI(_currentCtx, deptCategory, empCategory), - communicator()->stringToIdentity("DeptFactory")); + communicator()->stringToIdentity("DeptFactory")); adapter->activate(); communicator()->waitForShutdown(); diff --git a/cpp/demo/Database/Oracle/proc/Util.pc b/cpp/demo/Database/Oracle/proc/Util.pc index 9e96d81d88a..6a3ab69c03d 100644 --- a/cpp/demo/Database/Oracle/proc/Util.pc +++ b/cpp/demo/Database/Oracle/proc/Util.pc @@ -57,8 +57,8 @@ decodeName(const string& name) is >> result; if(!is || !is.eof()) { - cerr << "Unable to decode " << name << endl; - throw Ice::ObjectNotExistException(__FILE__, __LINE__); + cerr << "Unable to decode " << name << endl; + throw Ice::ObjectNotExistException(__FILE__, __LINE__); } return result; } |