#include "hdbcolumntype.h"
ClassImp(HDbColumnType)
ClassImp(HDbColCharType)
ClassImp(HDbColVcType)
ClassImp(HDbColNumType)
ClassImp(HDbColDateType)
ClassImp(HDbColLongType)
ClassImp(HDbColRowidType)
ClassImp(HDbColRawType)
HDbColumnType::HDbColumnType(const Char_t* n, Int_t l, Int_t p, Int_t s ) {
  
  SetName(n);
  varLength=l;
  dataPrecision=p;
  dataScale=s;
}  
TString HDbColumnType::getSelectString(const Char_t* col, const Char_t*) {
  
  
  Error("HDbColumnType::getNvlSelectString",
        "\n  Type %s of columnn %s actually not supported",
        GetName(), col);
  TString s("");
  return s;
}
TString HDbColumnType::getNvlSelectString(const Char_t* col, const Char_t* td,
                                          const Char_t*){
  
  
  TString s(getSelectString(col,td));
  return s;
}
HDbColCharType::HDbColCharType(Int_t l) : HDbColumnType("CHAR",l) {
  
  if (l<=0) varLength=1;
}
TString HDbColCharType::getTypeString() {
  
  TString s=("CHAR(");
  Char_t buf[10];
  sprintf(buf,"%i",varLength);
  s=s + buf + ")";
  return s;
}
TString HDbColCharType::getSelectString(const Char_t* col, const Char_t* td) {
  
  TString s;
  if (varLength>1) {
    if (strcmp(td,"'")==0) s=s + "''''||" + col + "||''''";
    else s=s + "'" + td + "'||" + col + "||'" + td + "'";
  }
  else s=col;
  return s;
}
TString HDbColCharType::getNvlSelectString(const Char_t* col, const Char_t* td,
                                           const Char_t* sNull) {
  
  
  TString s;
  if (varLength>1) {
    if (strcmp(td,"'")==0)
       s=s + "''''||nvl(" + col + ",'" + sNull + "')||''''";
    else s=s + "'" + td + "'||nvl(" + col + ",'" + sNull + "')||'"
         + td + "'";
  }
  else s=s + "nvl(" + col + ",'" + sNull + "')";
  return s;
}
HDbColVcType::HDbColVcType(Int_t l) : HDbColumnType("VARCHAR2",l) {
  
  if (l<=0) varLength=80;
}
TString HDbColVcType::getTypeString() {
  
  TString s=("VARCHAR2(");
  Char_t buf[10];
  sprintf(buf,"%i",varLength);
  s=s + buf + ")";
  return s;
}
TString HDbColVcType::getSelectString(const Char_t* col, const Char_t* td) {
  
  TString s;
  if (varLength>1) {
    if (strcmp(td,"'")==0) s=s + "''''||" + col + "||''''";
    else s=s + "'" + td + "'||" + col + "||'" + td + "'";
  }
  else s=col;
  return s;
}
TString HDbColVcType::getNvlSelectString(const Char_t* col, const Char_t* td,
                                           const Char_t* sNull) {
  
  
  TString s;
  if (varLength>1) {
    if (strcmp(td,"'")==0)
       s=s + "''''||nvl(" + col + ",'" + sNull + "')||''''";
    else s=s + "'" + td + "'||nvl(" + col + ",'" + sNull + "')||'"
         + td + "'";
  }
  else s=s + "nvl(" + col + ",'" + sNull + "')";
  return s;
}
HDbColNumType::HDbColNumType(Int_t p, Int_t s)
               : HDbColumnType("NUMBER",sizeof(Double_t),p,s) {
  
  if (p<=0) dataPrecision=40;
}
TString HDbColNumType::getTypeString() {
  
  TString s=("NUMBER");
  if (dataPrecision==40) return s;
  Char_t buf[100];
  sprintf(buf,"%i",dataPrecision);
  s=s + "(" + buf;
  if (dataScale>=0) {
    sprintf(buf,"%i",dataScale);
    s=s + "," + buf;
  }
  s=s + ")";
  return s;
}
TString HDbColNumType::getSelectString(const Char_t* col, const Char_t*) {
  
  
  TString s("to_char(");
  s=s + col + ")";
  return s;
}
TString HDbColNumType::getNvlSelectString(const Char_t* col, const Char_t*, const Char_t* sNull) {
  
  
  TString s("nvl(to_char(");
  s=s + col + "),'" + sNull + "')";
  return s;
}
HDbColDateType::HDbColDateType(Int_t l) : HDbColumnType("DATE",l) {
  
  if (l<=0) varLength=75;
}
TString HDbColDateType::getSelectString(const Char_t* col, const Char_t* td) {
  
  
  TString s;
  if (strcmp(td,"'")==0)
     s=s + "''''||to_char(" + col + ")||''''";
  else s=s + "'" + td + "'||to_char(" + col + ")||'" + td + "'";
  return s;
}
TString HDbColDateType::getNvlSelectString(const Char_t* col, const Char_t* td,
                                           const Char_t* sNull) {
  
  
  
  TString s;
  if (strcmp(td,"'")==0)
     s=s + "''''||nvl(to_char(" + col + "),'" + sNull + "')||''''";
  else s=s + "'" + td + "'||nvl(to_char(" + col + "),'" + sNull + "')||'"
         + td + "'";
  return s;
}
HDbColLongType::HDbColLongType(Int_t l) : HDbColumnType("LONG",l) {
  
  
  if (l<=0) varLength=32767;
}
TString HDbColRowidType::getSelectString(const Char_t* col, const Char_t*) {
  
  TString s("rowidtochar(");
  s=s + col + ")";
  return s;
}
TString HDbColRowidType::getNvlSelectString(const Char_t* col, const Char_t*,
                                            const Char_t* sNull) {
  
  
  TString s("nvl(rowidtochar(");
  s=s + col + "),'" + sNull + "')";
  return s;
}
HDbColRawType::HDbColRawType(Int_t l) : HDbColumnType("RAW",l) {
  
  
  if (l<=0) varLength=255;
}
TString HDbColRawType::getTypeString() {
  
  TString s=("RAW(");
  Char_t buf[10];
  sprintf(buf,"%i",varLength);
  s=s + buf + ")";
  return s;
}
Last change: Sat May 22 12:54:21 2010
Last generated: 2010-05-22 12:54
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.