Exemplo n.º 1
0
short SeqGenEntry::fetchNewRange(SequenceGeneratorAttributes &inSGA)
{
  Lng32 cliRC = 0;

  // fetch new range from Seq Generator database
  SequenceGeneratorAttributes sga;
  sga = inSGA;
  if (sga.getSGCache() == 0)
    sga.setSGCache(1); 

  sga.setSGRetryNum(getRetryNum());
  cliRC = SQL_EXEC_SeqGenCliInterface(&cliInterfaceArr_, &sga);
  if (cliRC < 0)
    return (short)cliRC;

  cachedStartValue_ = sga.getSGNextValue();
  cachedCurrValue_ = cachedStartValue_;
  cachedEndValue_ = sga.getSGEndValue();

  if (cachedStartValue_ > sga.getSGMaxValue())
    {
      return -1579; // max reached
    }

  fetchNewRange_ = FALSE;

  return 0;
}
short ElemDDLSGOptions::genSGA(SequenceGeneratorAttributes &sga)
{
  sga.setSGStartValue(getStartValue());
  sga.setSGIncrement(getIncrement());
  sga.setSGMinValue(getMinValue());
  sga.setSGMaxValue(getMaxValue());

  sga.setSGCache(getCache());
  sga.setSGCycleOption(isCycle());

  sga.setSGFSDataType(getFSDataType());

  sga.setSGResetOption(isReset());

  return 0;
}
Exemplo n.º 3
0
short SeqGenEntry::getNextSeqVal(SequenceGeneratorAttributes &sga, Int64 &seqVal)
{
  short rc = 0;

  if (NOT fetchNewRange_)
    {
      cachedCurrValue_ += sga.getSGIncrement();
      if (cachedCurrValue_ > cachedEndValue_)
	fetchNewRange_ = TRUE;
    }

  if (fetchNewRange_)
    {
      rc = fetchNewRange(sga);
      if (rc)
	return rc;
    }

  seqVal = cachedCurrValue_;

  return 0;
}