#include "hgupstoremed.h" #define SQLCA_STORAGE_CLASS extern #define ORACA_STORAGE_CLASS extern #include #include // ************************************************************************ // ---------------------- getMaxIndex ----------------------------------- // ************************************************************************ int HGupStoreMed::getMaxIndex() { // returns maximum MEDIUM_INDEX // returns -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 HGupStoreMed::getMaxIndex"); EXEC SQL WHENEVER NOT FOUND GOTO notfound; EXEC SQL SELECT MAX(MEDIUM_INDEX) INTO :MaxIndex INDICATOR :MaxIndex_Ind FROM HADES_OPER.MEDIA; if (MaxIndex_Ind>=0) { mediumIndex=MaxIndex; return mediumIndex; } notfound: return -1; } // ************************************************************************ // ---------------------- storeObj -------------------------------------- // ************************************************************************ long HGupStoreMed::storeObj() { // stores a new object in MEDIA mediumIndex++; if (mediumIndex <= 0) { cerr << "error in HGupStoreMed::storeObj: mediumIndex = " << mediumIndex << endl; return -1; }; EXEC SQL BEGIN DECLARE SECTION; int Medium_Index=mediumIndex; const char* Medium_Name=mediumName; const char* Material_Name=materialName; int Medium_Isvol=isvol; int Medium_Ifield=ifield; float Medium_Fieldm=fieldm; float Medium_Epsil=epsil; int Vers_Index=versIndex; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO sqlHandleError("sql error in HGupStoreMed::storeObj"); EXEC SQL INSERT INTO HADES_OPER.MEDIA (MEDIUM_INDEX, MEDIUM_NAME, MATERIAL_NAME, MEDIUM_ISVOL, MEDIUM_IFIELD, MEDIUM_FIELDM, MEDIUM_EPSIL, VERS_INDEX) VALUES (:Medium_Index, :Medium_Name, :Material_Name, :Medium_Isvol, :Medium_Ifield, :Medium_Fieldm, :Medium_Epsil, :Vers_Index); return sqlca.sqlcode; notfound: return -1; } // ************************************************************************ // ---------------------- printInput ------------------------------------ // ************************************************************************ void HGupStoreMed::printInput() { cout << "Insert in table MEDIA" << '\n'; cout << "MEDIUM_INDEX: " << mediumIndex << '\n'; cout << "MEDIUM_NAME: " << mediumName << '\n'; cout << "MATERIAL_NAME: " << materialName << '\n'; cout << "MEDIUM_ISVOL: " << isvol << '\n'; cout << "MEDIUM_IFIELD: " << ifield << '\n'; cout << "MEDIUM_FIELDM: " << fieldm << '\n'; cout << "MEDIUM_EPSIL: " << epsil << '\n'; cout << "VERS_INDEX: " << versIndex << '\n'; cout << "-------------------------------------------------------"<< '\n'; return; } // ************************************************************************ // ---------------------- writeInput ------------------------------------ // ************************************************************************ void HGupStoreMed::writeInput(ofstream & fout) { // writes input to logfile fout << "Insert in table MEDIA" << '\n'; fout << "MEDIUM_INDEX: " << mediumIndex << '\n'; fout << "MEDIUM_NAME: " << mediumName << '\n'; fout << "MATERIAL_NAME: " << materialName << '\n'; fout << "MEDIUM_ISVOL: " << isvol << '\n'; fout << "MEDIUM_IFIELD: " << ifield << '\n'; fout << "MEDIUM_FIELDM: " << fieldm << '\n'; fout << "MEDIUM_EPSIL: " << epsil << '\n'; fout << "VERS_INDEX: " << versIndex << '\n'; fout << "-------------------------------------------------------"<< '\n'; return; }