//*-- AUTHOR : Ilse Koenig //*-- Last modified : 31/05/2002 by I. Koenig //*-- Created : 04/04/2000 //_HADES_CLASS_DESCRIPTION ////////////////////////////////////////////////////////////////////////////// // HTofParOraIo // // Interface class to database Oracle for input/output of parameters needed // by the Tof // (uses the Oracle C/C++ precompiler) // ////////////////////////////////////////////////////////////////////////////// using namespace std; #include "htofparoraio.h" #include "hades.h" #include "hspectrometer.h" #include "htofdetector.h" #include "htoflookup.h" #include "htofcalpar.h" #include "htofdigipar.h" #include "htofgeompar.h" #include "hgeomcompositevolume.h" #include "htofclusterfpar.h" #include "hgeomoradetversion.h" #include #include #include #define SQLCA_STORAGE_CLASS extern #define ORACA_STORAGE_CLASS extern // Oracle communication area #include // SQL Communications Area #include ClassImp(HTofParOraIo) #define TOF_MAXSEC 6 #define TOF_MAXMODS 132 #define TOF_MAXRODS 1056 #define TOF_MAXSECRODS 176 HTofParOraIo::HTofParOraIo(HOraConn* pC) : HDetParOraIo(pC) { // constructor // sets the name of the I/O class "HTofParIo" // gets the pointer to the connection class fName="HTofParIo"; numModules=0; tofIds=0; secIds=0; initModules=0; geomVers=0; } HTofParOraIo::~HTofParOraIo() { // destructor if (tofIds) delete tofIds; if (secIds) delete secIds; if (initModules) delete initModules; if (geomVers) delete geomVers; } Bool_t HTofParOraIo::init(HParSet* pPar,Int_t* set) { // calls special read-function for each parameter container const Text_t* name=pPar->IsA()->GetName(); if (strcmp(name,"HTofClusterFPar")==0) return readCond((HParCond*)pPar,set); if (startIo(pPar)<=0) return kFALSE; if (strcmp(name,"HTofLookup")==0) return read(((HTofLookup*)pPar),set); if (strcmp(name,"HTofCalPar")==0) return read(((HTofCalPar*)pPar),set); if (strcmp(name,"HTofDigiPar")==0) return read(((HTofDigiPar*)pPar),set); if (strcmp(name,"HTofGeomPar")==0) return read(((HTofGeomPar*)pPar),set); // cout<<"initialization of "<GetName()<<" not possible from Oracle!"<IsA()->GetName(); if (strcmp(name,"HTofClusterFPar")==0) return writeCond((HParCond*)pPar); if (startIo(pPar)<=0) return 0; if (strcmp(name,"HTofCalPar")==0) return writePar((HTofCalPar*)pPar); if (strcmp(name,"HTofDigiPar")==0) return writePar((HTofDigiPar*)pPar); if (strcmp(name,"HTofGeomPar")==0) return writeAlignment((HTofGeomPar*)pPar); cout<<"No write-interface to Oracle for parameter container " <GetName()<0 && tofIds==0) readIds(); if (runStart==-1 || numModules<=0) { pPar->setInputVersion(-1,inputNumber); return -1; } return runStart; } Int_t HTofParOraIo::readIds() { // reads the id numbers of all modules defined for the actual run // and stores them in array tofIds // returns the number of modules found HTofDetector* det=(HTofDetector*)(gHades->getSetup()->getDetector("Tof")); maxModules=det->getMaxModules(); EXEC SQL BEGIN DECLARE SECTION; struct { int id[TOF_MAXMODS]; int sec[TOF_MAXMODS]; int mod[TOF_MAXMODS]; } mods; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("readIds()"); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT module_id, sector, segment INTO :mods FROM tof_ana.setup_at_run_hist; numModules=sqlca.sqlerrd[2]; if (numModules>0) { tofIds=new TArrayI(TOF_MAXMODS); for(Int_t i=0;iAddAt(0,i); secIds=new TArrayI(TOF_MAXSEC); for(Int_t i=0;iAddAt(0,i); initModules=new TArrayI(TOF_MAXMODS); } Int_t s, m, pos; for(Int_t i=0;igetModule(s,m)) { tofIds->AddAt(mods.id[i],pos); secIds->AddAt(mods.sec[i],s); } } // printIds(); return numModules; } void HTofParOraIo::printIds() { // prints the id numbers of all modules if (tofIds) { for(Int_t i=0;iAt(i*maxModules+j); } cout<<'\n'; } cout<<'\n'; } } Int_t HTofParOraIo::getLookupVersion(HTofLookup* pPar) { // reads the version for the TofLookup container valid at the start time // of the actual run // returns -1, if no data are found HParOraSet* oraSet=getOraSet(pPar); Int_t contVers=pPar->getInputVersion(inputNumber); if (contVers!=-1 && runStart>=oraSet->versDate[0] && runStart<=oraSet->versDate[1]) { return contVers; } Double_t dateRange[2]={-1.,1.e+12}; EXEC SQL BEGIN DECLARE SECTION; double c_since; double c_until; double r_since; double r_until; short c_since_ind; short c_until_ind; short r_since_ind; short r_until_ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("getLookupVersion(HTofLookup*)"); EXEC SQL WHENEVER NOT FOUND GOTO notfound; EXEC SQL SELECT hdate.to_ansitime(config_since), hdate.to_ansitime(config_until), hdate.to_ansitime(dc_since), hdate.to_ansitime(dc_until) INTO :c_since:c_since_ind, :c_until:c_until_ind, :r_since:r_since_ind, :r_until:r_until_ind FROM tof_ana.tof_lookup_time_range_hist; if (c_since_ind==-1||c_until_ind==-1||r_since_ind==-1||r_until_ind==-1) { oraSet->clearVersDate(); return -1; } dateRange[0]=c_since; dateRange[1]=c_until; if (r_since>dateRange[0]) dateRange[0]=r_since; if (r_untildateRange[0]) dateRange[0]=c_since; if (c_until_ind!=-1 && c_untilversDate[0] || runStart>oraSet->versDate[1] || dateRange[0]!=oraSet->versDate[0] || dateRange[1]!=oraSet->versDate[1]) { oraSet->versDate[0]=dateRange[0]; oraSet->versDate[1]=dateRange[1]; return getActRunId(); } else return contVers; notfound: oraSet->clearVersDate(); return -1; }; Bool_t HTofParOraIo::read(HTofLookup* pPar, Int_t* set) { // reads the lookup table (parameter container TofLookup) needed by the unpacker Int_t version=getLookupVersion(pPar); if (version==-1) { pPar->setInputVersion(-1,inputNumber); return kFALSE; } if (version==pPar->getInputVersion(inputNumber)) return kTRUE; pPar->clear(); initModules->Reset(); EXEC SQL BEGIN DECLARE SECTION; struct { int crate[TOF_MAXRODS]; int slot[TOF_MAXRODS]; int chan[TOF_MAXRODS]; char branch[TOF_MAXRODS][2]; int sec[TOF_MAXRODS]; int mod[TOF_MAXRODS]; int rod[TOF_MAXRODS]; char side[TOF_MAXRODS][2]; } lrec; struct { short crate[TOF_MAXRODS]; short slot[TOF_MAXRODS]; short chan[TOF_MAXRODS]; short branch[TOF_MAXRODS]; short sec[TOF_MAXRODS]; short mod[TOF_MAXRODS]; short rod[TOF_MAXRODS]; short side[TOF_MAXRODS]; } lrec_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("read(HTofLookup*,Int_t*)"); EXEC SQL DECLARE lookup_cur CURSOR FOR SELECT crate, slot, channel, branch, sector, module, rod, side FROM tof_ana.tof_lookup_at_histdate; EXEC SQL OPEN lookup_cur; EXEC SQL WHENEVER NOT FOUND CONTINUE; Int_t nbs=0, nbslast=0, s, m, pos; do { EXEC SQL FETCH lookup_cur INTO :lrec INDICATOR :lrec_Ind; nbs=sqlca.sqlerrd[2] - nbslast; nbslast+=nbs; for(Int_t i=0;ifill(lrec.crate[i]-1,lrec.slot[i]-1,lrec.branch[i][0], lrec.chan[i],s,m,lrec.rod[i]-1,lrec.side[i][0]); initModules->AddAt(pos+1,pos); } } } while (nbs==TOF_MAXRODS); EXEC SQL CLOSE lookup_cur; Bool_t allFound=kTRUE; Int_t n=TOF_MAXSEC*maxModules; for(Int_t i=0;i0 && initModules->At(i)<=0) allFound=kFALSE; } if (allFound) { pPar->setInputVersion(version,inputNumber); setChanged(pPar); printInfo(pPar->GetName()); } else pPar->clear(); return allFound; } Int_t HTofParOraIo::getVersion(HParSet* pPar,Int_t* set,Int_t* versions) { // reads the version for the calibration and digitisation parameters // valid for the current event file // returns -1, if no data are found HParOraSet* oraSet=getOraSet(pPar); if (oraSet->contextId==-1) return -1; Int_t contVers=pPar->getInputVersion(inputNumber); if (contVers!=-1 && runStart>=oraSet->versDate[0] && runStart<=oraSet->versDate[1]) return contVers; oraSet->clearVersDate(); Int_t tofSectors[TOF_MAXSEC]; putTofSectors(set,tofSectors); EXEC SQL BEGIN DECLARE SECTION; int context; struct { int sec[TOF_MAXSEC]; int vers[TOF_MAXSEC]; double since[TOF_MAXSEC]; double until[TOF_MAXSEC]; } parvers; EXEC SQL END DECLARE SECTION; context=oraSet->contextId; EXEC SQL WHENEVER SQLERROR DO showSqlError("getVersion(HParOraSet*,Int_t)"); EXEC SQL WHENEVER NOT FOUND CONTINUE; const Char_t* containerClass=pPar->IsA()->GetName(); if (strcmp(containerClass,"HTofCalPar")==0) { EXEC SQL SELECT sector, version, hdate.to_ansitime(valid_since), hdate.to_ansitime(valid_until) INTO :parvers FROM tof_ana.tof_calpar_vers_at_date WHERE context_id = :context; } else { if (strcmp(containerClass,"HTofDigiPar")==0) { EXEC SQL SELECT sector, version, hdate.to_ansitime(valid_since), hdate.to_ansitime(valid_until) INTO :parvers FROM tof_ana.tof_digipar_vers_at_date WHERE context_id = :context; } } for(Int_t i=0;iAt(s)>0 && tofSectors[s]>0) { versions[s]=parvers.vers[i]; if (parvers.since[i]>oraSet->versDate[0]) oraSet->versDate[0]=parvers.since[i]; if (parvers.until[i]versDate[1]) oraSet->versDate[1]=parvers.until[i]; } } if (oraSet->versDate[0]>=0) return getActRunId(); return -1; }; Bool_t HTofParOraIo::read(HTofCalPar* pPar, Int_t* set) { // reads the calibration parameters and fill the TofCalPar container Int_t contVers=pPar->getInputVersion(inputNumber); Int_t versions[TOF_MAXSEC]; Int_t version=getVersion(pPar,set,versions); if (version==-1) { pPar->setInputVersion(-1,inputNumber); return kFALSE; } if (contVers==version) return kTRUE; if (inputNumber==1) pPar->clear(); pPar->setInputVersion(version,inputNumber); initModules->Reset(); EXEC SQL BEGIN DECLARE SECTION; int vers; int sec; struct { int mod[TOF_MAXSECRODS]; int rod[TOF_MAXSECRODS]; float sl[TOF_MAXSECRODS]; float sr[TOF_MAXSECRODS]; float gv[TOF_MAXSECRODS]; float op[TOF_MAXSECRODS]; float ot[TOF_MAXSECRODS]; float pl[TOF_MAXSECRODS]; float pr[TOF_MAXSECRODS]; float al[TOF_MAXSECRODS]; float ga[TOF_MAXSECRODS]; float ep[TOF_MAXSECRODS]; float c1[TOF_MAXSECRODS]; float c2[TOF_MAXSECRODS]; float c3[TOF_MAXSECRODS]; } cal; struct { short mod[TOF_MAXSECRODS]; short rod[TOF_MAXSECRODS]; short sl[TOF_MAXSECRODS]; short sr[TOF_MAXSECRODS]; short gv[TOF_MAXSECRODS]; short op[TOF_MAXSECRODS]; short ot[TOF_MAXSECRODS]; short pl[TOF_MAXSECRODS]; short pr[TOF_MAXSECRODS]; short al[TOF_MAXSECRODS]; short ga[TOF_MAXSECRODS]; short ep[TOF_MAXSECRODS]; short c1[TOF_MAXSECRODS]; short c2[TOF_MAXSECRODS]; short c3[TOF_MAXSECRODS]; } cal_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("read(HTofCalPar*,Int_t*)"); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL DECLARE cal_cur CURSOR FOR SELECT module, rod, left_k, right_k, v_group, pos_k, tim_k, pedestal_l, pedestal_r, att_len, gain_asym, edep_k, tw_c1, tw_c2, tw_c3 FROM tof_ana.tof_calpar_data WHERE sector = :sec AND version = :vers; Int_t m=-1, pos=-1; for(Int_t s=0;sAt(s)>0 && versions[s]>0) { sec=s+1; vers=versions[s]; // cout<<"cal sector: "<AddAt(pos+1,pos); } } } } EXEC SQL CLOSE cal_cur; Bool_t allFound=kTRUE; Int_t n=TOF_MAXSEC*maxModules; for(Int_t i=0;i0) { if (initModules->At(i)>0) set[i]=0; else allFound=kFALSE; } } setChanged(pPar); printInfo(pPar->GetName()); return allFound; } Bool_t HTofParOraIo::read(HTofDigiPar* pPar, Int_t* set) { // reads the digitization parameters and fill the TofDigiPar container Int_t contVers=pPar->getInputVersion(inputNumber); Int_t versions[TOF_MAXSEC]; Int_t version=getVersion(pPar,set,versions); if (version==-1) { pPar->setInputVersion(-1,inputNumber); return kFALSE; } if (contVers==version) return kTRUE; if (inputNumber==1) pPar->clear(); pPar->setInputVersion(version,inputNumber); initModules->Reset(); EXEC SQL BEGIN DECLARE SECTION; int vers; int sec; struct { int mod[TOF_MAXSECRODS]; int rod[TOF_MAXSECRODS]; float hl[TOF_MAXSECRODS]; float ar[TOF_MAXSECRODS]; float al[TOF_MAXSECRODS]; float gv[TOF_MAXSECRODS]; float slt[TOF_MAXSECRODS]; float srt[TOF_MAXSECRODS]; int tlc[TOF_MAXSECRODS]; int trc[TOF_MAXSECRODS]; int tla[TOF_MAXSECRODS]; int tra[TOF_MAXSECRODS]; } digi; struct { short mod[TOF_MAXSECRODS]; short rod[TOF_MAXSECRODS]; short hl[TOF_MAXSECRODS]; short ar[TOF_MAXSECRODS]; short al[TOF_MAXSECRODS]; short gv[TOF_MAXSECRODS]; short slt[TOF_MAXSECRODS]; short srt[TOF_MAXSECRODS]; short tlc[TOF_MAXSECRODS]; short trc[TOF_MAXSECRODS]; short tla[TOF_MAXSECRODS]; short tra[TOF_MAXSECRODS]; } digi_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("read(HTofDigiPar*,Int_t*)"); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL DECLARE digi_cur CURSOR FOR SELECT module, rod, half_len, angle_ref, atten_len, group_vel,slope_left_tdc, slope_right_tdc, thr_left_cfd, thr_right_cfd, thr_left_adc, thr_right_adc FROM tof_ana.tof_digipar_data WHERE sector = :sec AND version = :vers; Int_t m=-1, pos=-1; for(Int_t s=0;sAt(s)>0 && versions[s]>0) { HTofDigiParSec& sector=(*pPar)[s]; sec=s+1; vers=versions[s]; // cout<<"Digi sector: "<AddAt(pos+1,pos); } } } } EXEC SQL CLOSE digi_cur; Bool_t allFound=kTRUE; Int_t n=TOF_MAXSEC*maxModules; for(Int_t i=0;i0) { if (initModules->At(i)>0) set[i]=0; else allFound=kFALSE; } } setChanged(pPar); printInfo(pPar->GetName()); return allFound; } Bool_t HTofParOraIo::read(HTofGeomPar* pPar, Int_t* set) { // reads the geometry of the TOF and fills the TofGeomPar container Bool_t allFound=kTRUE; Int_t detId=-1; if (!geomVers) { detId=getDetectorId(pPar->getDetectorName()); geomVers=new HGeomOraDetVersion(pPar->getDetectorName(),detId); } else { detId=geomVers->getDetectorId(); } if (detId<=0) { allFound=kFALSE; delete geomVers; geomVers=0; } if (detId>0&&pPar->isFirstInitialization()) { if (!readModGeomNames(pPar,set) || !readCompGeomNames(pPar,set)) { allFound=kFALSE; pPar->clear(); } else addGeomOraSet(pPar); } if (allFound) allFound=readDetectorGeometry(pPar,set,geomVers); return allFound; } Bool_t HTofParOraIo::readModGeomNames(HTofGeomPar* pPar,Int_t* set) { // reads the tof_pos_id of all modules EXEC SQL BEGIN DECLARE SECTION; struct { int tof[TOF_MAXMODS]; int sec[TOF_MAXMODS]; int mod[TOF_MAXMODS]; varchar oname[TOF_MAXMODS][9]; } mods; struct { short tof_Ind[TOF_MAXMODS]; short sec_Ind[TOF_MAXMODS]; short mod_Ind[TOF_MAXMODS]; short oname_Ind[TOF_MAXMODS]; } mods_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("readModGeomNames()"); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT module_id, sector, segment, geom_obj INTO :mods INDICATOR :mods_Ind FROM tof_ana.setup_at_run_hist; Int_t nMods=sqlca.sqlerrd[2]; Int_t pos, s, m; Char_t ref[10]; initModules->Reset(); for(Int_t i=0;igetModule(s,m); pos=s*maxModules + m; if (pMod && set[pos]) { if (mods_Ind.oname_Ind[i]!=-1) { mods.oname[i].arr[mods.oname[i].len]='\0'; pMod->SetName((Char_t*)(mods.oname[i].arr)); initModules->AddAt(pos+1,pos); strcpy(ref,(Char_t*)(mods.oname[i].arr)); ref[4]='1'; // reference module in sector 1 // not yet introduced in database pMod->setRefName(ref); Int_t mr=pPar->getModNumInMod(ref); HGeomCompositeVolume* refMod=pPar->getRefVolume(mr); if (refMod==0) { refMod=new HGeomCompositeVolume(pPar->getNumComponents()); refMod->SetName(ref); pPar->addRefVolume(refMod,mr); } pMod->setVolume(refMod); } } } Bool_t allFound=kTRUE; Int_t n=TOF_MAXSEC*maxModules; for(Int_t i=0;i0 && initModules->At(i)==0) allFound=kFALSE; } return allFound; } Bool_t HTofParOraIo::readCompGeomNames(HTofGeomPar* pPar,Int_t* set) { // reads the names of all rods in the geometry tables EXEC SQL BEGIN DECLARE SECTION; struct { int sec[TOF_MAXRODS]; int mod[TOF_MAXRODS]; int rod[TOF_MAXRODS]; varchar oname[TOF_MAXRODS][9]; } rods; struct { short sec_Ind[TOF_MAXRODS]; short mod_Ind[TOF_MAXRODS]; short rod_Ind[TOF_MAXRODS]; short oname_Ind[TOF_MAXRODS]; } rods_Ind; EXEC SQL END DECLARE SECTION; EXEC SQL WHENEVER SQLERROR DO showSqlError("readCompGeomNames(...)"); EXEC SQL WHENEVER NOT FOUND CONTINUE; EXEC SQL SELECT sector, segment, rod_number, r.geom_obj_name INTO :rods INDICATOR :rods_Ind FROM tof_ana.setup_at_run_hist s, tof_ana.rod r WHERE s.module_id=r.module_id; Int_t nRods=-1, pos, s, m; nRods=sqlca.sqlerrd[2]; for(Int_t k=0;kgetModule(s,m); pos=s*maxModules + m; if (pMod && set[pos]) { HGeomCompositeVolume* pRefMod=pMod->getRefVolume(); if (rods_Ind.oname_Ind[k]!=-1) { rods.oname[k].arr[rods.oname[k].len]='\0'; HGeomVolume* volu=pRefMod->getComponent((rods.rod[k]-1)); volu->SetName((Char_t*)(rods.oname[k].arr)); } } } Bool_t allFound=kTRUE; Int_t n=TOF_MAXSEC*maxModules; for(Int_t i=0;i0 && initModules->At(i)==0) allFound=kFALSE; } return allFound; } Int_t HTofParOraIo:: writePar(HTofCalPar* pPar) { // creates a new version and writes the calibration parameters to Oracle Int_t version=createVers(pPar); if (version==-1) return -1; EXEC SQL BEGIN DECLARE SECTION; int sec[TOF_MAXSECRODS]; int mod[TOF_MAXSECRODS]; int rod[TOF_MAXSECRODS]; int vers[TOF_MAXSECRODS]; float sl[TOF_MAXSECRODS]; float sr[TOF_MAXSECRODS]; float gv[TOF_MAXSECRODS]; float op[TOF_MAXSECRODS]; float ot[TOF_MAXSECRODS]; float pl[TOF_MAXSECRODS]; float pr[TOF_MAXSECRODS]; float al[TOF_MAXSECRODS]; float ga[TOF_MAXSECRODS]; float ep[TOF_MAXSECRODS]; float c1[TOF_MAXSECRODS]; float c2[TOF_MAXSECRODS]; float c3[TOF_MAXSECRODS]; int rows_to_insert; EXEC SQL END DECLARE SECTION; Int_t id, pos; for(Int_t s=0; sgetSize(); s++) { HTofCalParSec& rSec= (*pPar)[s]; Int_t nRod=0; for(Int_t m=0; mAt(pos); if (id>0) { for(Int_t c=0; csetChanged(kFALSE); return version; not_found: showSqlError("writePar(HTofCalPar*)"); rollback(); pPar->setChanged(kFALSE); return -1; } Int_t HTofParOraIo:: writePar(HTofDigiPar* pPar) { // creates a new version and writes the digitisation parameters to Oracle Int_t version=createVers(pPar); if (version==-1) return -1; EXEC SQL BEGIN DECLARE SECTION; int sec[TOF_MAXSECRODS]; int mod[TOF_MAXSECRODS]; int rod[TOF_MAXSECRODS]; int vers[TOF_MAXSECRODS]; float hl[TOF_MAXSECRODS]; float ar[TOF_MAXSECRODS]; float al[TOF_MAXSECRODS]; float gv[TOF_MAXSECRODS]; float slt[TOF_MAXSECRODS]; float srt[TOF_MAXSECRODS]; int tlc[TOF_MAXSECRODS]; int trc[TOF_MAXSECRODS]; int tla[TOF_MAXSECRODS]; int tra[TOF_MAXSECRODS]; int rows_to_insert; EXEC SQL END DECLARE SECTION; Int_t id, pos; for(Int_t s=0; sgetSize(); s++) { HTofDigiParSec& rSec= (*pPar)[s]; Int_t nRod=0; for(Int_t m=0; mAt(pos); if (id>0) { for(Int_t c=0; csetChanged(kFALSE); return version; not_found: showSqlError("writePar(HTofDigiPar*)"); rollback(); pPar->setChanged(kFALSE); return -1; } Int_t HTofParOraIo::createVers(HParSet* pPar) { // creates a new version for the calibration or digitization parameters // returns the new version cout<<"--------------- "<GetName()<<" ---------------\n"; if (strlen(pPar->getAuthor())==0) { Error("createVers(HParSet*)", "author of parameters not defined"); return -1; } if (strlen(pPar->getDescription())==0) { Error("createVers(HParSet*)", "descriction of parameters not defined"); return -1; } EXEC SQL BEGIN DECLARE SECTION; int vers=-1; int context; int run; char* creator; char* descript; EXEC SQL END DECLARE SECTION; context = getContextId(pPar->IsA()->GetName(),pPar->getParamContext()); if (context==-1) return -1; run=getActRunId(); creator=(Char_t*)pPar->getAuthor(); descript=(Char_t*)pPar->getDescription(); EXEC SQL WHENEVER SQLERROR GOTO not_found; EXEC SQL WHENEVER NOT FOUND GOTO not_found; const Char_t* contName=pPar->IsA()->GetName(); if (strcmp(contName,"HTofCalPar")==0) { EXEC SQL EXECUTE BEGIN SELECT tof_ana.tof_par_query.next_version INTO :vers FROM DUAL; INSERT INTO tof_ana.calpar_vers (vers_id, orig_context_id, run_id, author, description) VALUES (:vers, :context, :run, :creator, :descript); END; END-EXEC; } else { if (strcmp(contName,"HTofDigiPar")==0) { EXEC SQL EXECUTE BEGIN SELECT tof_ana.tof_par_query.next_version INTO :vers FROM DUAL; INSERT INTO tof_ana.digipar_vers (vers_id, orig_context_id, run_id, author, description) VALUES (:vers, :context, :run, :creator, :descript); END; END-EXEC; } } cout<<"Oracle version for "<GetName()<<" created: "<At(i)) { if (first) { cout<lastSec) { cout<