demo_with_rollback.cxx File Reference

#include "TVldTimeStamp.hxx"
#include "TDbi.hxx"
#include "TSK_DBI_Context.hxx"
#include "TDemo2_DB_Table.hxx"
#include "TResultSetHandle.hxx"
#include <iostream>
#include <string>
Include dependency graph for demo_with_rollback.cxx:

Go to the source code of this file.

Functions

Int_t DateTimeToUnixTime (const std::string &dateTime)
std::string UnixTimeToDateTime (Int_t unixSecs)
int main ()

Function Documentation

Int_t DateTimeToUnixTime ( const std::string &  dateTime  ) 

Definition at line 29 of file demo_with_rollback.cxx.

References TVldTimeStamp::GetSec(), and TDbi::MakeTimeStamp().

00029                                                     {
00030   return TDbi::MakeTimeStamp(dateTime).GetSec();
00031 }

Here is the call graph for this function:

int main (  ) 

Definition at line 46 of file demo_with_rollback.cxx.

References DateTimeToUnixTime(), TDbiResultSetHandle< T >::GetNumRows(), TDbiResultSetHandle< T >::GetRow(), TDbiResultSetHandle< T >::GetRowByIndex(), TDemo2_DB_Table::Print(), TSK_DBI_Context::SetTimeStamp(), SK_DBI_Log, and UnixTimeToDateTime().

00046            {
00047 
00048 
00049   // Examine the Database table DEMO_DB_TABLE every 5 days between the start
00050   // and end date.
00051 
00052   std::string start_date_time = "2008-12-30 00:00:00";
00053   std::string end_date_time   = "2009-03-01 00:00:00";
00054 
00055   Int_t start_unix_time = DateTimeToUnixTime(start_date_time);
00056   Int_t end_unix_time   = DateTimeToUnixTime(end_date_time);
00057 
00058   UInt_t required_id      = 1;
00059 
00060   for (Int_t current_unix_time = start_unix_time; current_unix_time <= end_unix_time; current_unix_time += 5*24*60*60) {
00061     TSK_DBI_Context context;
00062     context.SetTimeStamp(current_unix_time);
00063     TResultSetHandle<TDemo2_DB_Table> rs(context);
00064     SK_DBI_Log("_______________________________________________________________________________");
00065     Int_t numRows(rs.GetNumRows());
00066     if ( ! numRows )  SK_DBI_Log("Applying query at " << UnixTimeToDateTime(current_unix_time) << " ... failed to find any results.");
00067     else {
00068       SK_DBI_Log("Applying query at " << UnixTimeToDateTime(current_unix_time) << " ... result set contains " 
00069                                     << numRows << " rows as follows:-");
00070       for (Int_t irow = 0; irow<numRows; ++irow) rs.GetRow(irow)->Print();
00071       const TDemo2_DB_Table* required_row = rs.GetRowByIndex(required_id);
00072       if ( required_row ) {
00073         SK_DBI_Log("  required row " << 1);
00074         required_row->Print();
00075       }
00076       else SK_DBI_Log("  cannot find required row " << 1);      
00077     }
00078   }
00079 
00080   return 0;
00081 }

Here is the call graph for this function:

std::string UnixTimeToDateTime ( Int_t  unixSecs  ) 

Definition at line 33 of file demo_with_rollback.cxx.

References TDbi::MakeDateTimeString().

00033                                              {
00034   return TDbi::MakeDateTimeString(TVldTimeStamp(unixSecs,0));
00035 }

Here is the call graph for this function:


Generated on 11 Aug 2013 for SKDatabase by  doxygen 1.6.1