Package org.apache.derby.iapi.sql

Examples of org.apache.derby.iapi.sql.ResultDescription


        //getMetaData call is made.
        //Second check - if the statement was revalidated since last getMetaData call,
        //then gcDuringGetMetaData wouldn't match with current generated class name

                GeneratedClass currAc = null;
                ResultDescription resd = null;

                synchronized(execp) {
                    // DERBY-3823 Some other thread may be repreparing
                    do {
                        while (!execp.upToDate()) {
                            execp.rePrepare(lcc);
                        }

                        currAc = execp.getActivationClass();
                        resd = execp.getResultDescription();
                    } while (currAc == null);
                }

                if (gcDuringGetMetaData == null ||
                        !gcDuringGetMetaData.equals(currAc.getName())) {
                    rMetaData = null;
                    gcDuringGetMetaData = currAc.getName();
                }

                if (rMetaData == null && resd != null) {
                    // Internally, the result description has information
                    // which is used for insert, update and delete statements
                    // Externally, we decided that statements which don't
                    // produce result sets such as insert, update and delete
                    // should not return ResultSetMetaData.  This is enforced
                    // here
                    String statementType = resd.getStatementType();
                    if (statementType.equals("INSERT") ||
                            statementType.equals("UPDATE") ||
                            statementType.equals("DELETE"))
                        rMetaData = null;
                    else
View Full Code Here


    }

    int[] columnIndexes = null;
    if (firstExecute && activation.getAutoGeneratedKeysResultsetMode())
    {
      ResultDescription rd;
      Properties properties = new Properties();
      columnIndexes = activation.getAutoGeneratedKeysColumnIndexes();

      // Get the properties on the old heap
      rowChanger.getHeapConglomerateController().getInternalTablePropertySet(properties);
View Full Code Here

  //do following few checks before accepting updateXXX resultset api
  protected void checksBeforeUpdateXXX(String methodName, int columnIndex) throws SQLException {
      checksBeforeUpdateOrDelete(methodName, columnIndex);

      //1)Make sure for updateXXX methods, the column position is not out of range
      ResultDescription rd = theResults.getResultDescription();
      if (columnIndex < 1 || columnIndex > rd.getColumnCount())
        throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POSITION,
          new Integer(columnIndex), String.valueOf(rd.getColumnCount()));

      //2)Make sure the column corresponds to a column in the base table and it is not a derived column
      if (rd.getColumnDescriptor(columnIndex).getSourceTableName() == null)
        throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TABLE,
          methodName);

      //3)If column not updatable then throw an exception
      if (!getMetaData().isWritable(columnIndex))
View Full Code Here

                ExecCursorTableReference targetTable =
                        activation.getPreparedStatement().getTargetTable();
                // got the underlying (schema.)table name
                insertSQL.append(getFullBaseTableName(targetTable));
                ResultDescription rd = theResults.getResultDescription();

                insertSQL.append(" (");
                // in this for loop we are constructing list of column-names
                // and values (?) ,... part of the insert sql
                for (int i=1; i<=rd.getColumnCount(); i++) {
                    if (foundOneColumnAlready) {
                        insertSQL.append(",");
                        valuesSQL.append(",");
                    }
                    // using quotes around the column name
                    // to preserve case sensitivity
                    insertSQL.append(IdUtil.normalToDelimited(
                            rd.getColumnDescriptor(i).getName()));
                    if (columnGotUpdated[i-1]) {
                        valuesSQL.append("?");
                    } else {
                        valuesSQL.append("DEFAULT");
                    }
                    foundOneColumnAlready = true;
                }
                insertSQL.append(") ");
                valuesSQL.append(") ");
                insertSQL.append(valuesSQL);

                StatementContext currSC = lcc.getStatementContext();
                Activation parentAct = null;

                if (currSC != null) {
                    parentAct = currSC.getActivation();
                }

                // Context used for preparing, don't set any timeout (use 0)
                statementContext = lcc.pushStatementContext(
                        isAtomic,
                        false,
                        insertSQL.toString(),
                        null,
                        false,
                        0L);

                // A priori, the new statement context inherits the activation
                // of the existing statementContext, so that that activation
                // ends up as parent of the new activation 'act' created below,
                // which will be the activation of the pushed statement
                // context.
                statementContext.setActivation(parentAct);

                org.apache.derby.iapi.sql.PreparedStatement ps =
                        lcc.prepareInternalStatement(insertSQL.toString());
                Activation act = ps.getActivation(lcc, false);

                statementContext.setActivation(act);

                // in this for loop we are assigning values for parameters
                //in sql constructed earlier VALUES (?, ..)
                for (int i=1, paramPosition=0; i<=rd.getColumnCount(); i++) {
                    // if the column got updated, do following
                    if (columnGotUpdated[i-1]) { 
                        act.getParameterValueSet().
                                getParameterForSet(paramPosition++).
                                setValue(updateRow.getColumn(i));
View Full Code Here


            ExecCursorTableReference targetTable = activation.getPreparedStatement().getTargetTable();
            updateWhereCurrentOfSQL.append(getFullBaseTableName(targetTable));//got the underlying (schema.)table name
            updateWhereCurrentOfSQL.append(" SET ");
            ResultDescription rd = theResults.getResultDescription();

            for (int i=1; i<=rd.getColumnCount(); i++) { //in this for loop we are constructing columnname=?,... part of the update sql
                if (columnGotUpdated[i-1]) { //if the column got updated, do following
                    if (foundOneColumnAlready)
                        updateWhereCurrentOfSQL.append(",");
                    //using quotes around the column name to preserve case sensitivity
                    updateWhereCurrentOfSQL.append(IdUtil.normalToDelimited(
                            rd.getColumnDescriptor(i).getName()) + "=?");
                    foundOneColumnAlready = true;
                }
            }
            //using quotes around the cursor name to preserve case sensitivity
            updateWhereCurrentOfSQL.append(" WHERE CURRENT OF " +
                    IdUtil.normalToDelimited(getCursorName()));

            StatementContext currSC = lcc.getStatementContext();
            Activation parentAct = null;

            if (currSC != null) {
                parentAct = currSC.getActivation();
            }

            // Context used for preparing, don't set any timeout (use 0)
            statementContext = lcc.pushStatementContext(isAtomic, false, updateWhereCurrentOfSQL.toString(), null, false, 0L);

            // A priori, the new statement context inherits the activation of
            // the existing statementContext, so that that activation ends up
            // as parent of the new activation 'act' created below, which will
            // be the activation of the pushed statement context.
            statementContext.setActivation(parentAct);

            org.apache.derby.iapi.sql.PreparedStatement ps = lcc.prepareInternalStatement(updateWhereCurrentOfSQL.toString());
            Activation act = ps.getActivation(lcc, false);

            statementContext.setActivation(act);

            //in this for loop we are assigning values for parameters in sql constructed earlier with columnname=?,...
            for (int i=1, paramPosition=0; i<=rd.getColumnCount(); i++) {
                if (columnGotUpdated[i-1])  //if the column got updated, do following
                    act.getParameterValueSet().getParameterForSet(paramPosition++).setValue(updateRow.getColumn(i));
            }
            // Don't set any timeout when updating rows (use 0)
            // Execute the update where current of sql.
View Full Code Here

          rMetaData = null;
          gcDuringGetMetaData = execp.getActivationClass().getName();
        }
        if (rMetaData == null)
        {
          ResultDescription resd = preparedStatement.getResultDescription();
          if (resd != null)
          {
            // Internally, the result description has information
            // which is used for insert, update and delete statements
            // Externally, we decided that statements which don't
            // produce result sets such as insert, update and delete
            // should not return ResultSetMetaData.  This is enforced
            // here
            String statementType = resd.getStatementType();
            if (statementType.equals("INSERT") ||
                statementType.equals("UPDATE") ||
                statementType.equals("DELETE"))
              rMetaData = null;
            else
View Full Code Here

    triggerInfo = constants.getTriggerInfo();

    heapConglom = constants.conglomId;

    baseRowReadList = constants.getBaseRowReadList();
        ResultDescription resultDescription;
    if(passedInRsd ==null)
      resultDescription = activation.getResultDescription();
    else
      resultDescription = passedInRsd;
    /*
    ** We NEED a result description when we are going to
    ** to have to kick off a trigger.  In a replicated environment
    ** we don't get a result description when we are replaying
    ** source xacts on the target, which should never be the
    ** case for an UpdateResultSet.
    */
    if (SanityManager.DEBUG)
    {
      if (resultDescription == null)
      {
        SanityManager.ASSERT(triggerInfo == null, "triggers need a result description to pass to result sets given to users");
      }
    }

    if (fkInfoArray != null)
    {
      for (int i = 0; i < fkInfoArray.length; i++)
      {
        if (fkInfoArray[i].type == FKInfo.REFERENCED_KEY)
        {
          updatingReferencedKey = true;
          if (SanityManager.DEBUG)
          {
            SanityManager.ASSERT(constants.deferred, "updating referenced key but update not deferred, wuzzup?");
          }
        }
        else
       
          updatingForeignKey = true;
        }
      }
    }

    /* Get the # of columns in the ResultSet */
    resultWidth = resultDescription.getColumnCount();
   
    /*
    ** Calculate the # of columns in the base table.  The result set
    ** contains the before columns, the after columns, and the RowLocation,
    ** so the number of base columns is half of the number of result set
View Full Code Here

    hasBeforeRowTrigger = (triggerInfo != null) ?
        triggerInfo.hasTrigger(true, true) :
        false;

        ResultDescription resultDescription = activation.getResultDescription();

    // Is this a bulkInsert or regular insert?
    String insertMode = constants.getProperty("insertMode");

                RowLocation[] rla;

    if ((rla = constants.getAutoincRowLocation()) != null)
    {
      aiCache =
        new NumberDataValue[rla.length];
      for (int i = 0; i < resultDescription.getColumnCount(); i++)
      {
        if (rla[i] == null)
          continue;
        ResultColumnDescriptor rcd =
          resultDescription.getColumnDescriptor(i + 1);
        aiCache[i] = (NumberDataValue)rcd.getType().getNull();
      }
    }

    if (insertMode != null)
View Full Code Here

      if (targetTableDescriptor.getLockGranularity() == TableDescriptor.TABLE_LOCK_GRANULARITY)
      {
        lockMode = TransactionController.MODE_TABLE;
      }

      ResultDescription resultDescription = null;
      if(isDependentTable)
      {
        //triggers need the result description ,
        //dependent tables  don't have a source from generation time
        //to get the result description
View Full Code Here

  //do following few checks before accepting updateXXX resultset api
  protected void checksBeforeUpdateXXX(String methodName, int columnIndex) throws SQLException {
      checksBeforeUpdateOrDelete(methodName, columnIndex);

      //1)Make sure for updateXXX methods, the column position is not out of range
      ResultDescription rd = theResults.getResultDescription();
      if (columnIndex < 1 || columnIndex > rd.getColumnCount())
        throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POSITION,
          new Integer(columnIndex), String.valueOf(rd.getColumnCount()));

      //2)Make sure the column corresponds to a column in the base table and it is not a derived column
      if (rd.getColumnDescriptor(columnIndex).getSourceTableName() == null)
        throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TABLE,
          methodName);

      //3)If column not updatable then throw an exception
      if (!getMetaData().isWritable(columnIndex))
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.sql.ResultDescription

Copyright © 2018 www.massapicom. 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.