// @(#)root/net:$Id$
// Author: Sergey Linev   6/02/2006

/*************************************************************************
 * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers.               *
 * All rights reserved.                                                  *
 *                                                                       *
 * For the licensing terms see $ROOTSYS/LICENSE.                         *
 * For the list of contributors see $ROOTSYS/README/CREDITS.             *
 *************************************************************************/

#ifndef ROOT_TSQLStatement
#define ROOT_TSQLStatement

#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TString
#include "TString.h"
#endif
#ifndef ROOT_TDatime
#include "TDatime.h"
#endif
#include<vector>

class TSQLStatement : public TObject {

protected:
   TSQLStatement(Bool_t errout = kTRUE) : TObject(), fErrorCode(0),
     fErrorMsg(), fErrorOut(errout) { ClearError(); }

   Int_t     fErrorCode;  // error code of last operation
   TString   fErrorMsg;   // error message of last operation
   Bool_t    fErrorOut;   // enable error output 

   void                ClearError();
   void                SetError(Int_t code, const char* msg, const char* method = 0);

public:
   virtual ~TSQLStatement() {}

   virtual Int_t       GetBufferLength() const = 0;
   virtual Int_t       GetNumParameters() = 0;

   virtual Bool_t      NextIteration() = 0;

   virtual Bool_t      SetNull(Int_t) { return kFALSE; }
   virtual Bool_t      SetInt(Int_t, Int_t) { return kFALSE; }
   virtual Bool_t      SetUInt(Int_t, UInt_t) { return kFALSE; }
   virtual Bool_t      SetLong(Int_t, Long_t) { return kFALSE; }
   virtual Bool_t      SetLong64(Int_t, Long64_t) { return kFALSE; }
   virtual Bool_t      SetULong64(Int_t, ULong64_t) { return kFALSE; }
   virtual Bool_t      SetDouble(Int_t, Double_t) { return kFALSE; }
   virtual Bool_t      SetString(Int_t, const char*, Int_t = 256) { return kFALSE; }
   virtual Bool_t      SetDate(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
           Bool_t      SetDate(Int_t, const TDatime&);
   virtual Bool_t      SetTime(Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
           Bool_t      SetTime(Int_t, const TDatime&);
   virtual Bool_t      SetDatime(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t) { return kFALSE; }
           Bool_t      SetDatime(Int_t, const TDatime&);
   virtual Bool_t      SetTimestamp(Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t, Int_t = 0) { return kFALSE; }
           Bool_t      SetTimestamp(Int_t, const TDatime&);
   virtual void        SetTimeFormating(const char*) {}
   virtual Bool_t      SetBinary(Int_t, void*, Long_t, Long_t = 0x1000) { return kFALSE; }
   virtual Bool_t      SetLargeObject(Int_t col, void* mem, Long_t size, Long_t maxsize = 0x1000) { return SetBinary(col, mem, size, maxsize); }
#ifndef __MAKECINT__
   virtual Bool_t      SetVInt(Int_t, const std::vector<Int_t>, const char*, const char*) { return kFALSE; }
   virtual Bool_t      SetVUInt(Int_t, const std::vector<UInt_t>, const char*, const char*) { return kFALSE; }
   virtual Bool_t      SetVLong(Int_t, const std::vector<Long_t>, const char*, const char*) { return kFALSE; }
   virtual Bool_t      SetVLong64(Int_t, const std::vector<Long64_t>, const char*, const char*) { return kFALSE; }
   virtual Bool_t      SetVULong64(Int_t, const std::vector<ULong64_t>, const char*, const char*) { return kFALSE; }
   virtual Bool_t      SetVDouble(Int_t, const std::vector<Double_t>, const char*, const char*) { return kFALSE; }
#endif

   virtual Bool_t      Process() = 0;
   virtual Int_t       GetNumAffectedRows() { return 0; }

   virtual Bool_t      StoreResult() = 0;
   virtual Int_t       GetNumFields() = 0;
   virtual const char *GetFieldName(Int_t) = 0;
   virtual Bool_t      SetMaxFieldSize(Int_t, Long_t) { return kFALSE; }
   virtual Bool_t      NextResultRow() = 0;

   virtual Bool_t      IsNull(Int_t) { return kTRUE; }
   virtual Int_t       GetInt(Int_t) { return 0; }
   virtual UInt_t      GetUInt(Int_t) { return 0; }
   virtual Long_t      GetLong(Int_t) { return 0; }
   virtual Long64_t    GetLong64(Int_t) { return 0; }
   virtual ULong64_t   GetULong64(Int_t) { return 0; }
   virtual Double_t    GetDouble(Int_t) { return 0.; }
   virtual const char *GetString(Int_t) { return 0; }
   virtual Bool_t      GetBinary(Int_t, void* &, Long_t&) { return kFALSE; }
   virtual Bool_t      GetLargeObject(Int_t col, void* &mem, Long_t& size) { return GetBinary(col, mem, size); }

   virtual Bool_t      GetDate(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
   virtual Bool_t      GetTime(Int_t, Int_t&, Int_t&, Int_t&) { return kFALSE; }
   virtual Bool_t      GetDatime(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
           TDatime     GetDatime(Int_t);
           Int_t       GetYear(Int_t);
           Int_t       GetMonth(Int_t);
           Int_t       GetDay(Int_t);
           Int_t       GetHour(Int_t);
           Int_t       GetMinute(Int_t);
           Int_t       GetSecond(Int_t);
   virtual Bool_t      GetTimestamp(Int_t, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&, Int_t&) { return kFALSE; }
           TDatime     GetTimestamp(Int_t);
#ifndef __MAKECINT__
   virtual Bool_t      GetVInt(Int_t, std::vector<Int_t>&) { return kFALSE; }
   virtual Bool_t      GetVUInt(Int_t, std::vector<UInt_t>&) { return kFALSE; }
   virtual Bool_t      GetVLong(Int_t, std::vector<Long_t>&) { return kFALSE; }
   virtual Bool_t      GetVLong64(Int_t, std::vector<Long64_t>&) { return kFALSE; }
   virtual Bool_t      GetVULong64(Int_t, std::vector<ULong64_t>&) { return kFALSE; }
   virtual Bool_t      GetVDouble(Int_t, std::vector<Double_t>&) { return kFALSE; }
#endif

   virtual Bool_t      IsError() const { return GetErrorCode()!=0; }
   virtual Int_t       GetErrorCode() const;
   virtual const char* GetErrorMsg() const;
   virtual void        EnableErrorOutput(Bool_t on = kTRUE) { fErrorOut = on; }

   ClassDef(TSQLStatement, 0) //SQL statement
};

#endif
 TSQLStatement.h:1
 TSQLStatement.h:2
 TSQLStatement.h:3
 TSQLStatement.h:4
 TSQLStatement.h:5
 TSQLStatement.h:6
 TSQLStatement.h:7
 TSQLStatement.h:8
 TSQLStatement.h:9
 TSQLStatement.h:10
 TSQLStatement.h:11
 TSQLStatement.h:12
 TSQLStatement.h:13
 TSQLStatement.h:14
 TSQLStatement.h:15
 TSQLStatement.h:16
 TSQLStatement.h:17
 TSQLStatement.h:18
 TSQLStatement.h:19
 TSQLStatement.h:20
 TSQLStatement.h:21
 TSQLStatement.h:22
 TSQLStatement.h:23
 TSQLStatement.h:24
 TSQLStatement.h:25
 TSQLStatement.h:26
 TSQLStatement.h:27
 TSQLStatement.h:28
 TSQLStatement.h:29
 TSQLStatement.h:30
 TSQLStatement.h:31
 TSQLStatement.h:32
 TSQLStatement.h:33
 TSQLStatement.h:34
 TSQLStatement.h:35
 TSQLStatement.h:36
 TSQLStatement.h:37
 TSQLStatement.h:38
 TSQLStatement.h:39
 TSQLStatement.h:40
 TSQLStatement.h:41
 TSQLStatement.h:42
 TSQLStatement.h:43
 TSQLStatement.h:44
 TSQLStatement.h:45
 TSQLStatement.h:46
 TSQLStatement.h:47
 TSQLStatement.h:48
 TSQLStatement.h:49
 TSQLStatement.h:50
 TSQLStatement.h:51
 TSQLStatement.h:52
 TSQLStatement.h:53
 TSQLStatement.h:54
 TSQLStatement.h:55
 TSQLStatement.h:56
 TSQLStatement.h:57
 TSQLStatement.h:58
 TSQLStatement.h:59
 TSQLStatement.h:60
 TSQLStatement.h:61
 TSQLStatement.h:62
 TSQLStatement.h:63
 TSQLStatement.h:64
 TSQLStatement.h:65
 TSQLStatement.h:66
 TSQLStatement.h:67
 TSQLStatement.h:68
 TSQLStatement.h:69
 TSQLStatement.h:70
 TSQLStatement.h:71
 TSQLStatement.h:72
 TSQLStatement.h:73
 TSQLStatement.h:74
 TSQLStatement.h:75
 TSQLStatement.h:76
 TSQLStatement.h:77
 TSQLStatement.h:78
 TSQLStatement.h:79
 TSQLStatement.h:80
 TSQLStatement.h:81
 TSQLStatement.h:82
 TSQLStatement.h:83
 TSQLStatement.h:84
 TSQLStatement.h:85
 TSQLStatement.h:86
 TSQLStatement.h:87
 TSQLStatement.h:88
 TSQLStatement.h:89
 TSQLStatement.h:90
 TSQLStatement.h:91
 TSQLStatement.h:92
 TSQLStatement.h:93
 TSQLStatement.h:94
 TSQLStatement.h:95
 TSQLStatement.h:96
 TSQLStatement.h:97
 TSQLStatement.h:98
 TSQLStatement.h:99
 TSQLStatement.h:100
 TSQLStatement.h:101
 TSQLStatement.h:102
 TSQLStatement.h:103
 TSQLStatement.h:104
 TSQLStatement.h:105
 TSQLStatement.h:106
 TSQLStatement.h:107
 TSQLStatement.h:108
 TSQLStatement.h:109
 TSQLStatement.h:110
 TSQLStatement.h:111
 TSQLStatement.h:112
 TSQLStatement.h:113
 TSQLStatement.h:114
 TSQLStatement.h:115
 TSQLStatement.h:116
 TSQLStatement.h:117
 TSQLStatement.h:118
 TSQLStatement.h:119
 TSQLStatement.h:120
 TSQLStatement.h:121
 TSQLStatement.h:122
 TSQLStatement.h:123
 TSQLStatement.h:124