⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 internaltriggerexecutioncontext.java

📁 derby database source code.good for you.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
		}	}	/////////////////////////////////////////////////////////	//	// TriggerExectionContext	//	/////////////////////////////////////////////////////////	/**	 * Get the target table name upon which the 	 * trigger event is declared.	 *	 * @return the target table	 */	public String getTargetTableName()	{		return targetTableName;	}	/**	 * Get the target table UUID upon which the 	 * trigger event is declared.	 *	 * @return the uuid of the target table	 */	public UUID getTargetTableId()	{		return targetTableId;	}	/**	 * Get the type for the event that caused the	 * trigger to fire.	 *	 * @return the event type (e.g. UPDATE_EVENT)	 */	public int getEventType()	{		return dmlType;	}	/**	 * Get the text of the statement that caused the	 * trigger to fire.	 *	 * @return the statement text	 */	public String getEventStatementText()	{		return statementText;	}	/**	 * Get the columns that have been modified by the statement	 * that caused this trigger to fire.  If all columns are	 * modified, will return null (e.g. for INSERT or DELETE will	 * return null).	 *	 * @return an array of Strings	 */	public String[] getModifiedColumns()	{		return changedColNames;	}	/**	 * Find out of a column was changed, by column name	 *	 * @param columnName the column to check 	 *	 * @return true if the column was modified by this statement.	 * Note that this will always return true for INSERT	 * and DELETE regardless of the column name passed in.	 */	public boolean wasColumnModified(String columnName)	{		if (changedColNames == null)		{			return true;		}		for (int i = 0; i < changedColNames.length; i++)		{			if (changedColNames[i].equals(columnName))			{				return true;			}		}		return false;	}	/**	 * Find out of a column was changed, by column number	 *	 * @param columnNumber the column to check 	 *	 * @return true if the column was modified by this statement.	 * Note that this will always return true for INSERT	 * and DELETE regardless of the column name passed in.	 */	public boolean wasColumnModified(int columnNumber)	{		if (changedColIds == null)		{			return true;		}		for (int i = 0; i < changedColNames.length; i++)		{			if (changedColIds[i] == columnNumber)			{				return true;			}		}		return false;	}	/**	 * Returns a result set row the old images of the changed rows.	 * For a row trigger, the result set will have a single row.  For	 * a statement trigger, this result set has every row that has	 * changed or will change.  If a statement trigger does not affect 	 * a row, then the result set will be empty (i.e. ResultSet.next()	 * will return false).	 *	 * @return the ResultSet containing before images of the rows 	 * changed by the triggering event.	 *	 * @exception SQLException if called after the triggering event has	 * completed	 */	public java.sql.ResultSet getOldRowSet() throws SQLException	{		ensureProperContext();		if (beforeResultSet == null)		{			return null;		}		try		{			CursorResultSet brs = beforeResultSet;			/* We should really shallow clone the result set, because it could be used			 * at multiple places independently in trigger action.  This is a bug found			 * during the fix of beetle 4373.			 */			if (brs instanceof TemporaryRowHolderResultSet)				brs = (CursorResultSet) ((TemporaryRowHolderResultSet) brs).clone();			else if (brs instanceof TableScanResultSet)				brs = (CursorResultSet) ((TableScanResultSet) brs).clone();			brs.open();			java.sql.ResultSet rs = cc.getResultSet(brs);			resultSetVector.addElement(rs);			return rs;		} catch (StandardException se)		{			throw PublicAPI.wrapStandardException(se);		}	}	/**	 * Returns a result set row the new images of the changed rows.	 * For a row trigger, the result set will have a single row.  For	 * a statement trigger, this result set has every row that has	 * changed or will change.  If a statement trigger does not affect 	 * a row, then the result set will be empty (i.e. ResultSet.next()	 * will return false).	 *	 * @return the ResultSet containing after images of the rows 	 * changed by the triggering event.	 *	 * @exception SQLException if called after the triggering event has	 * completed	 */	public java.sql.ResultSet getNewRowSet() throws SQLException	{		ensureProperContext();		if (afterResultSet == null)		{			return null;		}		try		{			/* We should really shallow clone the result set, because it could be used			 * at multiple places independently in trigger action.  This is a bug found			 * during the fix of beetle 4373.			 */			CursorResultSet ars = afterResultSet;			if (ars instanceof TemporaryRowHolderResultSet)				ars = (CursorResultSet) ((TemporaryRowHolderResultSet) ars).clone();			else if (ars instanceof TableScanResultSet)				ars = (CursorResultSet) ((TableScanResultSet) ars).clone();			ars.open();			java.sql.ResultSet rs = cc.getResultSet(ars);			resultSetVector.addElement(rs);			return rs;		} catch (StandardException se)		{			throw PublicAPI.wrapStandardException(se);		}	}	/**	 * Like getBeforeResultSet(), but returns a result set positioned	 * on the first row of the before result set.  Used as a convenience	 * to get a column for a row trigger.  Equivalent to getBeforeResultSet()	 * followed by next().	 *	 * @return the ResultSet positioned on the old row image.	 *	 * @exception SQLException if called after the triggering event has	 * completed	 */	public java.sql.ResultSet getOldRow() throws SQLException	{		java.sql.ResultSet rs = getOldRowSet();		if (rs != null)			rs.next();				return rs;	}	/**	 * Like getAfterResultSet(), but returns a result set positioned	 * on the first row of the before result set.  Used as a convenience	 * to get a column for a row trigger.  Equivalent to getAfterResultSet()	 * followed by next().	 *	 * @return the ResultSet positioned on the new row image.	 *	 * @exception SQLException if called after the triggering event has	 * completed	 */	public java.sql.ResultSet getNewRow() throws SQLException	{		java.sql.ResultSet rs = getNewRowSet();		if (rs != null)			rs.next();		return rs;	}		public Long getAutoincrementValue(String identity)	{		// first search the hashtable-- this represents the ai values generated		// by this trigger.		if (aiHT != null)			{				Long value = (Long)aiHT.get(identity);				if (value != null)					return value;			}						// If we didn't find it in the hashtable search in the counters which		// represent values inherited by trigger from insert statements.		if (aiCounters != null)		{			for (int i = 0; i < aiCounters.size(); i++)			{				AutoincrementCounter aic = 					(AutoincrementCounter)aiCounters.elementAt(i);				//				System.out.println("in itec:getaivalue " + aic);				if (identity.equals(aic.getIdentity()))				{					//					System.out.println("in itec:getvalue--returning " +  aic.getCurrentValue());					return aic.getCurrentValue();				}			}		}				// didn't find it-- return NULL.		return null;	}	/**	 * Copy a hashtable of autoincrement values into the trigger 	 * execution context hashtable of autoincrement values.	 */	public void copyHashtableToAIHT(Hashtable from)	{		if (from == null)			return;		if (aiHT == null)			aiHT = new Hashtable();		for (Enumeration e = from.keys(); e.hasMoreElements(); )		{			Object key = e.nextElement();			Object value = from.get(key);			aiHT.put(key, value);			//			System.out.println(" in itec:chte-- " + key + " " + value);		}	}			/** 	 * Reset Autoincrement counters to the beginning or the end.	 * 	 * @param		begin		if True, reset the AutoincremnetCounter to the	 *                          beginning-- used to reset the counters for the	 * 							next trigger. If false, reset it to the end--	 *                          this sets up the counter appropriately for a	 *                          AFTER STATEMENT trigger.	 */	public void resetAICounters(boolean begin)	{		if (aiCounters == null)			return;		afterRow = null;		int size = aiCounters.size();		for (int i = 0; i < size; i++)		{			AutoincrementCounter aic = 				(AutoincrementCounter)aiCounters.elementAt(i);			aic.reset(begin);		}	}			/**	 * Update Autoincrement Counters from the last row inserted.	 *	 */	public void updateAICounters() throws StandardException	{		if (aiCounters == null)			return;		int size = aiCounters.size();		for (int i = 0; i < size; i++)		{			AutoincrementCounter aic = 				(AutoincrementCounter)aiCounters.elementAt(i);			DataValueDescriptor dvd = afterRow.getColumn(aic.getColumnPosition());			aic.update(dvd.getLong());		}	}	public String toString() {		return triggerd.getName();	}}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -