source: trunk/Mars/datacenter/macros/insertdate.C@ 19826

Last change on this file since 19826 was 8107, checked in by tbretz, 18 years ago
*** empty log message ***
File size: 2.9 KB
Line 
1/* ======================================================================== *\
2!
3! *
4! * This file is part of MARS, the MAGIC Analysis and Reconstruction
5! * Software. It is distributed to you in the hope that it can be a useful
6! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
7! * It is distributed WITHOUT ANY WARRANTY.
8! *
9! * Permission to use, copy, modify and distribute this software and its
10! * documentation for any purpose is hereby granted without fee,
11! * provided that the above copyright notice appear in all copies and
12! * that both that copyright notice and this permission notice appear
13! * in supporting documentation. It is provided "as is" without express
14! * or implied warranty.
15! *
16!
17!
18! Author(s): Daniela Dorner, 01/2005 <mailto:dorner@astro.uni-wuerzburg.de>
19!
20! Copyright: MAGIC Software Development, 2000-2006
21!
22!
23\* ======================================================================== */
24
25/////////////////////////////////////////////////////////////////////////////
26//
27// insertdate.C
28// ============
29//
30// This macro is inserting a date into the table SequenceBuildStatus.
31// It is executed by the script copyscript, which copies the slow control
32// data to the appropriate directory and inserts the information into the
33// database.
34//
35// Usage:
36// .x insertdate.C+("date")
37//
38// Make sure, that database and password are corretly set in a resource
39// file called sql.rc and the resource file is found.
40//
41// Returns 0 in case of failure and 1 in case of success.
42//
43/////////////////////////////////////////////////////////////////////////////
44
45#include <iostream>
46#include <iomanip>
47
48#include <TEnv.h>
49
50#include <MSQLMagic.h>
51
52using namespace std;
53
54int insertdate(TString date)
55{
56 TEnv env("sql.rc");
57
58 MSQLMagic serv(env);
59 if (!serv.IsConnected())
60 {
61 cout << "ERROR - Connection to database failed." << endl;
62 return 0;
63 }
64 cout << "insertdate" << endl;
65 cout << "----------" << endl;
66 cout << endl;
67 cout << "Connected to " << serv.GetName() << endl;
68 cout << endl;
69
70 //insert entry for date into the table SequenceBuildStatus,
71 // if entry is not yet existing
72 if (!serv.ExistStr("fDate", "SequenceBuildStatus", date))
73 {
74 TString vals(Form("fDate='%s', fCCFilled=Now()", date.Data()));
75
76 const Int_t rc = serv.Insert("SequenceBuildStatus", vals);
77 if (rc==kFALSE) // Query failed
78 return -1;
79 //if (rc<0) // Dummy mode
80 // return 0;
81 }
82 else
83 {
84 cout << date << " already exists... do update. " << endl;
85
86 const Int_t rc = serv.Update("SequenceBuildStatus",
87 "fCCFilled=Now(), fExclusionsDone=NULL, fSequenceEntriesBuilt=NULL",
88 Form("fDate='%s'", date.Data()));
89
90 if (rc==kFALSE) // Query failed
91 return -1;
92 //if (rc<0) // Dummy mode
93 // return 0;
94
95 }
96
97 return 1;
98}
99
100
Note: See TracBrowser for help on using the repository browser.