#include "hgupstorevers.h" #define SQLCA_STORAGE_CLASS extern #define ORACA_STORAGE_CLASS extern #include #include // ************************************************************************ // ---------------------- getNewVersionIndex --------------------------- // ************************************************************************ int HGupStoreVers::getNewVersionIndex() { // sets VersIndex used by all store routines // returns versIndex (-1 if error occures) EXEC SQL BEGIN DECLARE SECTION; int MaxIndex; short MaxIndex_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO sqlHandleError("sql error in HGupStore::getNewVersionIndex"); EXEC SQL WHENEVER NOT FOUND GOTO notfound; EXEC SQL SELECT MAX(VERS_INDEX) INTO :MaxIndex INDICATOR :MaxIndex_Ind FROM HADES_GEOM.GEOM_VERSIONS; if (MaxIndex_Ind>=0) { versIndex=MaxIndex+1; return versIndex; } notfound: return -1; } // ************************************************************************ // ---------------------- storeObj -------------------------------------- // ************************************************************************ long HGupStoreVers::storeObj() { // stores a new version in GEOM_VERSIONS if (versIndex <= 0) { cerr << "error in HGupStoreVers::storeObj: versIndex = " << versIndex << endl; return -1; } EXEC SQL BEGIN DECLARE SECTION; int Vers_Index=versIndex; int Vers=versIndex; const char* Comm1=comment1; const char* Comm2=comment2; const char* File=filename; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO sqlHandleError("sql error in HGupStoreVers::storeObj"); EXEC SQL INSERT INTO HADES_GEOM.GEOM_VERSIONS (VERS_INDEX, VERSION, COMMENT1, COMMENT2, FILENAME) VALUES (:Vers_Index, :Vers, :Comm1, :Comm2, :File); return sqlca.sqlcode; notfound: return -1; } // ************************************************************************ // ---------------------- updateObj ------------------------------------- // ************************************************************************ long HGupStoreVers::updateObj() { // changes COMMENT1 and FILENAME in GEOM_VERSIONS EXEC SQL BEGIN DECLARE SECTION; int Vers_Index=versIndex; const char* Comm1=comment1; const char* File=filename; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO sqlHandleError("sql error in HGupStoreVers::updateObj"); EXEC SQL WHENEVER NOT FOUND GOTO notfound; EXEC SQL UPDATE HADES_GEOM.GEOM_VERSIONS SET COMMENT1 = :Comm1, FILENAME = :File WHERE VERS_INDEX = :Vers_Index; return sqlca.sqlcode; notfound: sqlHandleError("sql error in HGupStoreVers::updateObj notfound"); return sqlca.sqlcode; } // ************************************************************************ // ---------------------- printInput ------------------------------------ // ************************************************************************ void HGupStoreVers::printInput() { cout << "Insert in table GEOM_VERSIONS" << '\n'; cout << "VERS_INDEX: " << versIndex << '\n'; cout << "VERSION: " << versIndex << '\n'; cout << "COMMENT1: " << comment1 << '\n'; cout << "COMMENT2: " << comment2 << '\n'; cout << "FILENAME: " << filename << '\n'; cout << "-------------------------------------------------------"<< '\n'; return; } // ************************************************************************ // ---------------------- writeInput ------------------------------------ // ************************************************************************ void HGupStoreVers::writeInput(ofstream & fout) { // writes input to logfile fout << "Insert in table GEOM_VERSIONS" << '\n'; fout << "VERS_INDEX: " << versIndex << '\n'; fout << "VERSION: " << versIndex << '\n'; fout << "COMMENT1: " << comment1 << '\n'; fout << "COMMENT2: " << comment2 << '\n'; fout << "FILENAME: " << filename << '\n'; fout << "-------------------------------------------------------"<< '\n'; return; }