Examples of NumberDataValue


Examples of org.apache.derby.iapi.types.NumberDataValue

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(source == null || source instanceof SQLDouble,
    "getSeconds for a timestamp was given a source other than a SQLDouble");
    }
    NumberDataValue result;

        if (isNull()) {
            return nullValueDouble();
        }

    if (source != null)
      result = source;
    else
      result = new SQLDouble();

    result.setValue((double)(SQLTime.getSecond(encodedTime))
        + ((double)nanos)/1.0e9);

    return result;
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

  public NumberDataValue
    getSetAutoincrementValue(int columnPosition, long increment)
    throws StandardException
  {
    long startValue = 0;
                NumberDataValue dvd;
    int index = columnPosition - 1// all our indices are 0 based.

    /* As in DB2, only for single row insert: insert into t1(c1) values (..) do
     * we return the correct most recently generated identity column value.  For
     * multiple row insert, or insert with sub-select, the return value is non-
     * deterministic, and is the previous return value of the IDENTITY_VAL_LOCAL
     * function, before the insert statement.  Also, DB2 can have at most 1 identity
     * column per table.  The return value won't be affected either if Derby
     * table has more than one identity columns.
     */
    setIdentity = (! autoincrementGenerated) && isSourceRowResultSet();
    autoincrementGenerated = true;

      if (bulkInsert)
      {
      ColumnDescriptor cd = td.getColumnDescriptor(columnPosition);
      long ret;

      // for bulk insert we have the table descriptor
      //      System.out.println("in bulk insert");
      if (aiCache[index].isNull())
      {
        if (bulkInsertReplace)
        {
          startValue = cd.getAutoincStart();
        }
        else
        {
          dvd = dd.getSetAutoincrementValue(
                constants.autoincRowLocation[index],
              tc, false, aiCache[index], true);
          startValue = dvd.getLong();
        }
        lcc.autoincrementCreateCounter(td.getSchemaName(),
                         td.getName(),
                         cd.getColumnName(),
                         new Long(startValue),
                         increment,
                         columnPosition);
     
      }     
      ret = lcc.nextAutoincrementValue(td.getSchemaName(),
                       td.getName(),
                       cd.getColumnName());
      aiCache[columnPosition - 1].setValue(ret);
   

    else
    {
      NumberDataValue newValue;
      TransactionController nestedTC = null, tcToUse = tc;

      try
      {
        nestedTC = tc.startNestedUserTransaction(false);
        tcToUse = nestedTC;
      }

      catch (StandardException se)
      {
        // If I cannot start a Nested User Transaction use the parent
        // transaction to do all the work.
        tcToUse = tc;
      }

      try
      {
        /* If tcToUse == tc, then we are using parent xaction-- this
           can happen if for some reason we couldn't start a nested
           transaction
        */
        newValue = dd.getSetAutoincrementValue(
               constants.autoincRowLocation[index],
               tcToUse, true, aiCache[index], (tcToUse == tc));
      }

      catch (StandardException se)
      {
        if (tcToUse == tc)
        {
          /* we've using the parent xaction and we've timed out; just
             throw an error and exit.
          */
          throw se;
        }

        if (se.getMessageId().equals(SQLState.LOCK_TIMEOUT))
        {
          // if we couldn't do this with a nested xaction, retry with
          // parent-- we need to wait this time!
          newValue = dd.getSetAutoincrementValue(
                  constants.autoincRowLocation[index],
                  tc, true, aiCache[index], true);
        }
        else if (se.getMessageId().equals(SQLState.LANG_OUTSIDE_RANGE_FOR_DATATYPE))
        {
          // if we got an overflow error, throw a more meaningful
          // error message
          throw StandardException.newException(
                         SQLState.LANG_AI_OVERFLOW,
                         se,
                         constants.getTableName(),
                         constants.getColumnName(index));
        }
        else throw se;
      }
      finally
      {
        // no matter what, commit the nested transaction; if something
        // bad happened in the child xaction lets not abort the parent
        // here.
        if (nestedTC != null)
        {
          nestedTC.commit();
          nestedTC.destroy();
        }
      }
      aiCache[index] = newValue;
      if (setIdentity)
        identityVal = newValue.getLong();
    }

    return aiCache[index];
   
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

                heapCC.fetch(rl, row.getRowArray(), columnToRead, wait);

            columnToUpdate.set(columnNum - 1); // current value.

            // while the Row interface is 1 based.
            NumberDataValue currentAI = (NumberDataValue)row.getColumn(columnNum);
            long currentAIValue = currentAI.getLong();
           
            if (doUpdate)
            {
                // we increment and store the new value in SYSCOLUMNS
                NumberDataValue increment = (NumberDataValue)row.getColumn(columnNum + 2);
                currentAI = currentAI.plus(currentAI, increment, currentAI);
                row.setColumn(columnNum, currentAI);
                heapCC.replace(rl, row.getRowArray(), columnToUpdate);
            }
               
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

    if (incrementNeeded)
    {
      ExecRow readRow = ti.getRow(tc, keyRow,
                  SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID);
      NumberDataValue increment =
        (NumberDataValue)readRow.getColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTINC);
      aiValue += increment.getLong();
    }
    row.setColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTVALUE,
            new SQLLongint(aiValue));

    ti.updateRow(keyRow, row,
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

                    TransactionController.MODE_RECORD,
                    TransactionController.ISOLATION_REPEATABLE_READ);

            heapCC.fetch( rowLocation, row.getRowArray(), columnToUpdate, wait );

      NumberDataValue oldValueOnDisk = (NumberDataValue) row.getColumn( columnNum );

            SQLLongint expectedOldValue;
            if ( oldValue == null ) { expectedOldValue = new SQLLongint(); }
            else { expectedOldValue = new SQLLongint( oldValue.longValue() ); }
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

       */
      value = addend.getClone();
    }
    else
    {
      NumberDataValue  input = (NumberDataValue)addend;
      NumberDataValue nv = (NumberDataValue) value;

      value = nv.plus(
            input,            // addend 1
            nv,    // addend 2
            nv)// result
    }
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

                heapCC.fetch(rl, row.getRowArray(), columnToRead, wait);

            columnToUpdate.set(columnNum - 1); // current value.

            // while the Row interface is 1 based.
            NumberDataValue currentAI = (NumberDataValue)row.getColumn(columnNum);
            long currentAIValue = currentAI.getLong();
            NumberDataValue increment = (NumberDataValue)row.getColumn(columnNum + 2);
           
            if (doUpdate)
            {
                // we increment and store the new value in SYSCOLUMNS
                currentAI = currentAI.plus(currentAI, increment, currentAI);
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

    if (incrementNeeded)
    {
      ExecRow readRow = ti.getRow(tc, keyRow,
                  SYSCOLUMNSRowFactory.SYSCOLUMNS_INDEX1_ID);
      NumberDataValue increment =
        (NumberDataValue)readRow.getColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTINC);
      aiValue += increment.getLong();
    }
    row.setColumn(SYSCOLUMNSRowFactory.SYSCOLUMNS_AUTOINCREMENTVALUE,
            dvf.getDataValue(aiValue));

    ti.updateRow(keyRow, row,
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

    if (SanityManager.DEBUG)
    {
      SanityManager.ASSERT(source == null || source instanceof SQLDouble,
    "getSeconds for a timestamp was given a source other than a SQLDouble");
    }
    NumberDataValue result;

        if (isNull()) {
            return nullValueDouble();
        }

    if (source != null)
      result = source;
    else
      result = new SQLDouble();

    result.setValue((double)(SQLTime.getSecond(encodedTime))
        + ((double)nanos)/1.0e9);

    return result;
  }
View Full Code Here

Examples of org.apache.derby.iapi.types.NumberDataValue

                heapCC.fetch(rl, row.getRowArray(), columnToRead, wait);

            columnToUpdate.set(columnNum - 1); // current value.

            // while the Row interface is 1 based.
            NumberDataValue currentAI = (NumberDataValue)row.getColumn(columnNum);
            long currentAIValue = currentAI.getLong();
            NumberDataValue increment = (NumberDataValue)row.getColumn(columnNum + 2);
           
            if (doUpdate)
            {
                // we increment and store the new value in SYSCOLUMNS
                currentAI = currentAI.plus(currentAI, increment, currentAI);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.