Examples of StatementContext


Examples of org.apache.derby.iapi.sql.conn.StatementContext

        // Check that the cursor is not positioned on insertRow
        checkNotOnInsertRow();
       
        setupContextStack();
        LanguageConnectionContext lcc = getEmbedConnection().getLanguageConnection();
        StatementContext statementContext = null;
        try {
            if (currentRowHasBeenUpdated == false) //nothing got updated on this row
                return; //nothing to do since no updates were made to this row

            //now construct the update where current of sql
            boolean foundOneColumnAlready = false;
            StringBuffer updateWhereCurrentOfSQL = new StringBuffer("UPDATE ");
            CursorActivation activation = lcc.lookupCursorActivation(getCursorName());


            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);
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

            checkNotOnInsertRow();

            setupContextStack();
           
            LanguageConnectionContext lcc = getEmbedConnection().getLanguageConnection();
            StatementContext statementContext = null;
           
            //now construct the delete where current of sql
            try {
                StringBuffer deleteWhereCurrentOfSQL = new StringBuffer("DELETE FROM ");
                CursorActivation activation = lcc.lookupCursorActivation(getCursorName());
                deleteWhereCurrentOfSQL.append(getFullBaseTableName(activation.getPreparedStatement().getTargetTable()));//get the underlying (schema.)table name
                //using quotes around the cursor name to preserve case sensitivity
                deleteWhereCurrentOfSQL.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, deleteWhereCurrentOfSQL.toString(), null, false, 0L);
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

           * Push and pop a StatementContext around a next call so
           * that the ResultSet will get correctly closed down on an
           * error. (Cache the LanguageConnectionContext)
           */
                    // No timeout for this operation (use 0)
          StatementContext statementContext =
                        lcc.pushStatementContext(isAtomic,
             concurrencyOfThisResultSet==java.sql.ResultSet.CONCUR_READ_ONLY,
             getSQLText(),
                                                 getParameterValueSet(),
                                                 false, 0L);
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

                         boolean sync,
                         int commitflag,
                         boolean requestedByUser)
     throws StandardException
  {
    StatementContext statementContext = getStatementContext();
    if (requestedByUser  &&
      (statementContext != null) &&
      statementContext.inUse() &&
      statementContext.isAtomic())
    {
      throw StandardException.newException(SQLState.LANG_NO_COMMIT_IN_NESTED_CONNECTION);
    }

    // Log commit to error log, if appropriate
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

    *
   * @exception StandardException thrown on failure
   */
  private void doRollback(boolean xa, boolean requestedByUser) throws StandardException
  {
    StatementContext statementContext = getStatementContext();
    if (requestedByUser &&
      (statementContext != null) &&
      statementContext.inUse() &&
      statementContext.isAtomic())
    {
      throw StandardException.newException(SQLState.LANG_NO_ROLLBACK_IN_NESTED_CONNECTION);
    }

    // Log rollback to error log, if appropriate
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

    cc.setInUse(true);

    // Save off the current isolation level on entry so that it gets restored
    cc.setEntryIsolationLevel( getCurrentIsolationLevel());

    StatementContext sc = getStatementContext();
    if (sc.getSystemCode())
      cc.setReliability(CompilerContext.INTERNAL_SQL_LEGAL);

    /*
     * Set the compilation schema when its UUID is available.
     * i.e.:  Schema may not have been physically created yet, so
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

    int          parentStatementDepth = statementDepth;
    boolean        inTrigger = false;
    boolean        parentIsAtomic = false;

    // by default, assume we are going to use the outermost statement context
    StatementContext  statementContext = statementContexts[0];

    /*
    ** If we haven't allocated any statement contexts yet, allocate
    ** the outermost stmt context now and push it.
    */
    if (statementContext == null)
    {
      statementContext = statementContexts[0] = new GenericStatementContext(this);
    }
    else if (statementDepth > 0)
    {
      StatementContext  parentStatementContext;
      /*
      ** We also cache a 2nd statement context, though we still
      ** push and pop it. Note, new contexts are automatically pushed.
      */
      if (statementDepth == 1)
      {
        statementContext = statementContexts[1];

        if (statementContext == null)
          statementContext = statementContexts[1] = new GenericStatementContext(this);
        else
          statementContext.pushMe();

        parentStatementContext = statementContexts[0];
      }
      else
      {
        parentStatementContext = getStatementContext();
        statementContext = new GenericStatementContext(this);
      }

      inTrigger = parentStatementContext.inTrigger() || (outermostTrigger == parentStatementDepth);
      parentIsAtomic = parentStatementContext.isAtomic();
      statementContext.setSQLAllowed(parentStatementContext.getSQLAllowed(), false);
      if (parentStatementContext.getSystemCode())
        statementContext.setSystemCode();
    }

    incrementStatementDepth();

View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

  /**
   * @see LanguageConnectionContext#setIsolationLevel
   */
  public void setIsolationLevel(int isolationLevel) throws StandardException
  {
    StatementContext stmtCtxt = getStatementContext();
    if (stmtCtxt!= null && stmtCtxt.inTrigger())
      throw StandardException.newException(SQLState.LANG_NO_XACT_IN_TRIGGER, getTriggerExecutionContext().toString());

    // find if there are any held cursors from previous isolation level.
    // if yes, then throw an exception that isolation change not allowed until
    // the held cursors are closed.
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

        }

        /* Add the dependency to the StatementContext, so that
         * it can be cleared on a pre-execution error.
         */
        StatementContext sc = (StatementContext) cm.getContext(org.apache.derby.iapi.reference.ContextId.LANG_STATEMENT);
        sc.addDependency(dy);
      }
      else
      {
        /* Add a stored dependency */
        LanguageConnectionContext  lcc = getLanguageConnectionContext(cm);
View Full Code Here

Examples of org.apache.derby.iapi.sql.conn.StatementContext

  public void checkCancellationFlag()
        throws
            StandardException
  {
        LanguageConnectionContext lcc = getLanguageConnectionContext();
        StatementContext localStatementContext = lcc.getStatementContext();
        if (localStatementContext == null) {
            return;
        }

    InterruptStatus.throwIf(lcc);

        if (localStatementContext.isCancelled()) {
            throw StandardException.newException(SQLState.LANG_STATEMENT_CANCELLED_OR_TIMED_OUT);
        }
    }
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.