Ignore:
Timestamp:
04/13/05 09:29:47 (19 years ago)
Author:
Daniela Dorner
Message:
*** empty log message ***
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/MagicSoft/Mars/datacenter/macros/fillcalib.C

    r6933 r6935  
    6363#include <TFile.h>
    6464#include <TSQLResult.h>
     65#include <TSQLRow.h>
    6566
    6667#include "MSQLServer.h"
     
    7071
    7172using namespace std;
     73
     74// --------------------------------------------------------------------------
     75//
     76// Checks whether an entry is already existing
     77//
     78Bool_t ExistStr(MSQLServer &serv, const char *column, const char *table, Int_t test)
     79{
     80    TString query(Form("SELECT %s FROM %s WHERE %s='%d'", column, table, column, test));
     81    TSQLResult *res = serv.Query(query);
     82    if (!res)
     83        return kFALSE;
     84
     85    TSQLRow *row;
     86
     87    Bool_t rc = kFALSE;
     88    while ((row=res->Next()))
     89    {
     90        if ((*row)[0])
     91        {
     92            rc = kTRUE;
     93            break;
     94        }
     95    }
     96
     97    delete res;
     98
     99    return rc;
     100}
     101
    72102
    73103int Process(MSQLServer &serv, TString fname, Bool_t dummy)
     
    125155    cout << "  Max.Cluster: (i/o)  " << Form("%3d", (int)clumax) << endl;                 // Max Cluster
    126156
     157    TString query;
     158    if (!ExistStr(serv, "fSequenceFirst", "MyMagic.Calibration", seq))
     159    {
     160
     161        query = Form("INSERT MyMagic.Calibration SET"
     162                     " fSequenceFirst=%d,"
     163                     " fUnsuitableInner=%d, "
     164                     " fUnsuitableOuter=%d, "
     165                     " fUnreliableInner=%d, "
     166                     " fUnreliableOuter=%d, "
     167                     " fIsolatedInner=%d, "
     168                     " fIsolatedOuter=%d, "
     169                     " fIsolatedMaxCluster=%d",
     170                     seq, (int)unsin, (int)unsout, (int)unrin,
     171                     (int)unrout, (int)isoin, (int)isoout, (int)clumax);
     172    }
     173    else
     174    {
     175        query = Form("UPDATE MyMagic.Calibration SET"
     176                     " fUnsuitableInner=%d, "
     177                     " fUnsuitableOuter=%d, "
     178                     " fUnreliableInner=%d, "
     179                     " fUnreliableOuter=%d, "
     180                     " fIsolatedInner=%d, "
     181                     " fIsolatedOuter=%d, "
     182                     " fIsolatedMaxCluster=%d"
     183                     " WHERE fSequenceFirst=%d,",
     184                     (int)unsin, (int)unsout, (int)unrin,(int)unrout,
     185                     (int)isoin, (int)isoout, (int)clumax, seq);
     186    }
     187
    127188    if (dummy)
    128189        return 0;
    129 
    130     TString query = Form("INSERT MyMagic.Calibration SET"
    131                          " fSequenceFirst=%d,"
    132                          " fUnsuitableInner=%d, "
    133                          " fUnsuitableOuter=%d, "
    134                          " fUnreliableInner=%d, "
    135                          " fUnreliableOuter=%d, "
    136                          " fIsolatedInner=%d, "
    137                          " fIsolatedOuter=%d, "
    138                          " fIsolatedMaxCluster=%d",
    139                          seq, (int)unsin, (int)unsout, (int)unrin,
    140                          (int)unrout, (int)isoin, (int)isoout, (int)clumax);
    141 
    142190
    143191    TSQLResult *res = serv.Query(query);
     
    147195        return 0;
    148196    }
     197    delete res;
    149198
    150199    return 1;
Note: See TracChangeset for help on using the changeset viewer.