Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

oracle.javatools.db
Class Trigger

java.lang.Object
  extended by oracle.javatools.db.AbstractDBObject
      extended by oracle.javatools.db.AbstractBuildableObject
          extended by oracle.javatools.db.AbstractSystemObject
              extended by oracle.javatools.db.AbstractSchemaObject
                  extended by oracle.javatools.db.PlSql
                      extended by oracle.javatools.db.Trigger
All Implemented Interfaces:
DBObject, SchemaObject, SourceObject, SystemObject, Copyable, DynamicPropertySet

public class Trigger
extends PlSql

Model of a database Trigger. A trigger is essentially a block of pl/sql that will fire on certain defined events on a Table, View, Schema or database itself.


Nested Class Summary
static class Trigger.BaseType
          Base type for the Trigger (i.e.
static class Trigger.Timing
          Timing of a trigger - at what point relative to the trigger event the trigger's code will be executed.
 
Nested classes/interfaces inherited from class oracle.javatools.db.AbstractDBObject
AbstractDBObject.ChildSupport
 
Field Summary
static java.lang.String ALTER_EVENT
           
static java.lang.String ANALYZE_EVENT
           
static java.lang.String ASSOCIATE_STATISTICS_EVENT
           
static java.lang.String AUDIT_EVENT
           
static java.lang.String COMMENT_EVENT
           
static java.lang.String CREATE_EVENT
           
static java.lang.String DB_ROLE_CHANGE_EVENT
           
static java.lang.String DDL_EVENT
           
static java.lang.String DELETE_EVENT
           
static java.lang.String DISASSOCIATE_STATISTICS_EVENT
           
static java.lang.String DROP_EVENT
           
static java.lang.String GRANT_EVENT
           
static java.lang.String INSERT_EVENT
           
static java.lang.String LOGOFF_EVENT
           
static java.lang.String LOGON_EVENT
           
static java.lang.String NOAUDIT_EVENT
           
static java.lang.String RENAME_EVENT
           
static java.lang.String REVOKE_EVENT
           
static java.lang.String SERVERERROR_EVENT
           
static java.lang.String SHUTDOWN_EVENT
           
static java.lang.String STARTUP_EVENT
           
static java.lang.String SUSPEND_EVENT
           
static java.lang.String TRUNCATE_EVENT
           
static java.lang.String TYPE
           
static java.lang.String UPDATE_EVENT
           
 
Fields inherited from class oracle.javatools.db.PlSql
BLOCK_TYPE
 
Fields inherited from class oracle.javatools.db.AbstractSystemObject
m_listeners
 
Fields inherited from interface oracle.javatools.db.DBObject
COMMENT
 
Constructor Summary
Trigger()
           
Trigger(Schema schema, java.lang.String name)
           
 
Method Summary
 java.lang.String getBaseSchemaName()
          Gets the schema name for this trigger.
 Trigger.BaseType getBaseType()
          Gets the base type of the trigger.
 java.lang.String getCode()
          Gets the list of PL/SQL code of the trigger, ie from the BEGIN or DECLARE, to the matching END statement.
 DBObjectID[] getColumnIDs()
           
 java.lang.String[] getEvents()
          Gets the list of events for the trigger.
static java.util.List getEvents(Trigger.BaseType type, Trigger.Timing timing)
          Returns the valie events for the given BaseType and Timing.
 java.lang.String[] getReferenceNames()
          Deprecated. - see getReferencingOldAs() and getReferencingNewAs()
 java.lang.String getReferencingNewAs()
          Gets the name used in the REFERENCING AS NEW clause of the trigger.
 java.lang.String getReferencingOldAs()
          Gets the name used in the REFERENCING AS OLD clause of the trigger.
 java.lang.String getSource()
          Gets the source to create the trigger.
 DBObjectID getTableID()
          Gets the table name for the trigger.
 Schema getTableOwner()
          Deprecated. - use getBaseSchemaName()
 Trigger.Timing getTiming()
          Gets the timing (before/after) of the trigger.
 java.lang.String getType()
          Returns the type of this object.
 java.lang.String getWhenClause()
          Gets the WHEN clause of the trigger.
static boolean isDatabaseOnlyEvent(java.lang.String event)
          Returns true if the given event String is only applicable to databases (i.e.
 boolean isEnabled()
          Gets whether this Trigger is enabled.
 boolean isStatementLevel()
          Gets whether or not the trigger is statement level.
 void setBaseSchema(Schema schema)
          Convenience method that calls setBaseSchemaName(String) with the given schema's name.
 void setBaseSchemaName(java.lang.String baseSchemaName)
          Sets the schema name that this trigger has as its base.
 void setBaseType(Trigger.BaseType baseType)
          Sets the base type of the trigger.
 void setCode(java.lang.String code)
          Sets the list of PL/SQL code of the trigger, ie from the BEGIN or DECLARE, to the matching END statement.
 void setColumnIDs(DBObjectID[] ids)
           
 void setEnabled(boolean enabled)
          Sets whether this Trigger is enabled.
 void setEvents(java.lang.String[] events)
          Sets the list of events for the trigger.
 void setReferenceNames(java.lang.String[] names)
          Deprecated. - see setReferencingOldAs(java.lang.String) and setReferencingNewAs(java.lang.String)
 void setReferencingNewAs(java.lang.String referencingNewAs)
          Sets the name used in the REFERENCING AS NEW clause of the trigger.
 void setReferencingOldAs(java.lang.String referencingOldAs)
          Sets the name used in the REFERENCING AS OLD clause of the trigger.
 void setSource(java.lang.String source)
          Sets the source to create the trigger.
 void setStatementLevel(boolean statementLevel)
          Sets whether or not the trigger is statement level.
 void setTableID(DBObjectID tableID)
          Sets the table name for the trigger.
 void setTableOwner(Schema owner)
          Deprecated. - see information on getTableOwner().
 void setTiming(Trigger.Timing timing)
          Sets the timing (before/after) of the trigger.
 void setWhenClause(java.lang.String whenClause)
          Sets the WHEN clause of the trigger.
 
Methods inherited from class oracle.javatools.db.PlSql
copyToImpl, equalsImpl, getSourceInterrogator, isPlSql
 
Methods inherited from class oracle.javatools.db.AbstractSchemaObject
addObjectListener, getProperty, getSchema, removeObjectListener, setProperty, setSchema
 
Methods inherited from class oracle.javatools.db.AbstractSystemObject
addObjectListener, fireObjectUpdated, getParent, removeObjectListener
 
Methods inherited from class oracle.javatools.db.AbstractBuildableObject
checkInit, checkInit, getOwnedObjectsImpl, getProperties, getReferenceIDsImpl, needsInitialization
 
Methods inherited from class oracle.javatools.db.AbstractDBObject
changeParent, compareToImpl, copyObject, copyTo, copyTo, copyTo, copyTo, equals, findOwnedObject, findOwnedObject, findOwnedObject, getChildSupport, getID, getName, getOwnedObjects, getOwnedObjects, getProperty, getReferenceIDs, hashCode, includeOwnedObject, includesType, includesType, removeThisAsParent, replaceReferenceIDs, setID, setName, setProperties, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface oracle.javatools.db.SchemaObject
addObjectListener, getSchema, removeObjectListener, setSchema
 
Methods inherited from interface oracle.javatools.db.SystemObject
addObjectListener, fireObjectUpdated, removeObjectListener
 
Methods inherited from interface oracle.javatools.db.DBObject
copyTo, copyTo, copyTo, findOwnedObject, findOwnedObject, getID, getName, getOwnedObjects, getOwnedObjects, getParent, getReferenceIDs, replaceReferenceIDs, setID, setName
 
Methods inherited from interface oracle.javatools.util.DynamicPropertySet
getProperties, getProperty, getProperty, setProperties, setProperty
 

Field Detail

TYPE

public static final java.lang.String TYPE
See Also:
Constant Field Values

INSERT_EVENT

public static final java.lang.String INSERT_EVENT
See Also:
Constant Field Values

DELETE_EVENT

public static final java.lang.String DELETE_EVENT
See Also:
Constant Field Values

UPDATE_EVENT

public static final java.lang.String UPDATE_EVENT
See Also:
Constant Field Values

ALTER_EVENT

public static final java.lang.String ALTER_EVENT
See Also:
Constant Field Values

ANALYZE_EVENT

public static final java.lang.String ANALYZE_EVENT
See Also:
Constant Field Values

ASSOCIATE_STATISTICS_EVENT

public static final java.lang.String ASSOCIATE_STATISTICS_EVENT
See Also:
Constant Field Values

AUDIT_EVENT

public static final java.lang.String AUDIT_EVENT
See Also:
Constant Field Values

COMMENT_EVENT

public static final java.lang.String COMMENT_EVENT
See Also:
Constant Field Values

CREATE_EVENT

public static final java.lang.String CREATE_EVENT
See Also:
Constant Field Values

DISASSOCIATE_STATISTICS_EVENT

public static final java.lang.String DISASSOCIATE_STATISTICS_EVENT
See Also:
Constant Field Values

DB_ROLE_CHANGE_EVENT

public static final java.lang.String DB_ROLE_CHANGE_EVENT
See Also:
Constant Field Values

DROP_EVENT

public static final java.lang.String DROP_EVENT
See Also:
Constant Field Values

GRANT_EVENT

public static final java.lang.String GRANT_EVENT
See Also:
Constant Field Values

NOAUDIT_EVENT

public static final java.lang.String NOAUDIT_EVENT
See Also:
Constant Field Values

RENAME_EVENT

public static final java.lang.String RENAME_EVENT
See Also:
Constant Field Values

REVOKE_EVENT

public static final java.lang.String REVOKE_EVENT
See Also:
Constant Field Values

TRUNCATE_EVENT

public static final java.lang.String TRUNCATE_EVENT
See Also:
Constant Field Values

DDL_EVENT

public static final java.lang.String DDL_EVENT
See Also:
Constant Field Values

SERVERERROR_EVENT

public static final java.lang.String SERVERERROR_EVENT
See Also:
Constant Field Values

LOGON_EVENT

public static final java.lang.String LOGON_EVENT
See Also:
Constant Field Values

LOGOFF_EVENT

public static final java.lang.String LOGOFF_EVENT
See Also:
Constant Field Values

STARTUP_EVENT

public static final java.lang.String STARTUP_EVENT
See Also:
Constant Field Values

SHUTDOWN_EVENT

public static final java.lang.String SHUTDOWN_EVENT
See Also:
Constant Field Values

SUSPEND_EVENT

public static final java.lang.String SUSPEND_EVENT
See Also:
Constant Field Values
Constructor Detail

Trigger

public Trigger()

Trigger

public Trigger(Schema schema,
               java.lang.String name)
Method Detail

isDatabaseOnlyEvent

public static boolean isDatabaseOnlyEvent(java.lang.String event)
Returns true if the given event String is only applicable to databases (i.e. isn't a DDL event that can be applied to a schema as well as a database).

Parameters:
event - the event string to query
Returns:
false if the event is DDL or DML

getEvents

public static java.util.List getEvents(Trigger.BaseType type,
                                       Trigger.Timing timing)
Returns the valie events for the given BaseType and Timing.


getType

public java.lang.String getType()
Description copied from interface: DBObject
Returns the type of this object. Valid types include things like tables, views, synonyms, and columns.

Returns:
a string describing the type of object.

isEnabled

public boolean isEnabled()
Gets whether this Trigger is enabled.


setEnabled

public void setEnabled(boolean enabled)
Sets whether this Trigger is enabled.


getTiming

public Trigger.Timing getTiming()
Gets the timing (before/after) of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setTiming

public void setTiming(Trigger.Timing timing)
Sets the timing (before/after) of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


isStatementLevel

public boolean isStatementLevel()
Gets whether or not the trigger is statement level. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setStatementLevel

public void setStatementLevel(boolean statementLevel)
Sets whether or not the trigger is statement level. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getEvents

public java.lang.String[] getEvents()
Gets the list of events for the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setEvents

public void setEvents(java.lang.String[] events)
Sets the list of events for the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getBaseSchemaName

public java.lang.String getBaseSchemaName()
Gets the schema name for this trigger. This is only valid if the base type of the trigger is Trigger.BaseType.SCHEMA.

See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setBaseSchemaName

public void setBaseSchemaName(java.lang.String baseSchemaName)
Sets the schema name that this trigger has as its base. This is only valid for Trigger.BaseType.SCHEMA triggers.

See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setBaseSchema

public void setBaseSchema(Schema schema)
Convenience method that calls setBaseSchemaName(String) with the given schema's name.

Parameters:
schema - the schema whose name is to be used as the baseSchemaName property. If null, the baseSchemaName is set to null.
See Also:
setBaseSchemaName(String)

getTableOwner

@Deprecated
public Schema getTableOwner()
Deprecated. - use getBaseSchemaName()

This method is deprecated. If you want the table's schema use getTableID(), resolve it and get the schema. If you want the base schema for a Trigger.BaseType.SCHEMA trigger use getBaseSchemaName().


setTableOwner

@Deprecated
public void setTableOwner(Schema owner)
Deprecated. - see information on getTableOwner().

Sets the table owner for the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getTableID

public DBObjectID getTableID()
Gets the table name for the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setTableID

public void setTableID(DBObjectID tableID)
Sets the table name for the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getBaseType

public Trigger.BaseType getBaseType()
Gets the base type of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setBaseType

public void setBaseType(Trigger.BaseType baseType)
Sets the base type of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.

Parameters:
type -

getWhenClause

public java.lang.String getWhenClause()
Gets the WHEN clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setWhenClause

public void setWhenClause(java.lang.String whenClause)
Sets the WHEN clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getColumnIDs

public DBObjectID[] getColumnIDs()

setColumnIDs

public void setColumnIDs(DBObjectID[] ids)

getCode

public java.lang.String getCode()
Gets the list of PL/SQL code of the trigger, ie from the BEGIN or DECLARE, to the matching END statement. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setCode

public void setCode(java.lang.String code)
Sets the list of PL/SQL code of the trigger, ie from the BEGIN or DECLARE, to the matching END statement. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setReferencingNewAs

public void setReferencingNewAs(java.lang.String referencingNewAs)
Sets the name used in the REFERENCING AS NEW clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getReferencingNewAs

public java.lang.String getReferencingNewAs()
Gets the name used in the REFERENCING AS NEW clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


setReferencingOldAs

public void setReferencingOldAs(java.lang.String referencingOldAs)
Sets the name used in the REFERENCING AS OLD clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getReferencingOldAs

public java.lang.String getReferencingOldAs()
Gets the name used in the REFERENCING AS OLD clause of the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.


getReferenceNames

@Deprecated
public java.lang.String[] getReferenceNames()
Deprecated. - see getReferencingOldAs() and getReferencingNewAs()


setReferenceNames

@Deprecated
public void setReferenceNames(java.lang.String[] names)
Deprecated. - see setReferencingOldAs(java.lang.String) and setReferencingNewAs(java.lang.String)


getSource

public java.lang.String getSource()
Gets the source to create the trigger. See setSource(java.lang.String) for limitations on the use of getSource(), setSource() and the other get/set methods of this class.

Specified by:
getSource in interface SourceObject
Overrides:
getSource in class PlSql
Returns:
The source

setSource

public void setSource(java.lang.String source)
Sets the source to create the trigger.

The source is the entire Trigger definition as it would appear in the USER_SOURCE view. This source by definition covers all the other attributes of a Trigger listed in this class, and which have their own get and set methods. However, as the ALTER TRIGGER statement is very limited in its capabilities, a modification to a trigger is usually made by resubmitting the enitire source (typically with CREATE OR REPLACE).

The trigger class itself however, is not responsible for keeping its internal representation of the source and the other declarative properties in step.

If changes are made via the setTiming(oracle.javatools.db.Trigger.Timing), setEvents(java.lang.String[]), setCode(java.lang.String) methods etc, it will be necessary to use the DDLGenerator to construct the full source, and then set this using this method.

If changes are made to the source via this method, it will be necessary to use the PlSqlDeclarator to set the other attributes correctly.

Specified by:
setSource in interface SourceObject
Overrides:
setSource in class PlSql

Oracle Fusion Middleware Java API Reference for Oracle Extension SDK Reference
11g Release 1 (11.1.1.6.0)

E13403-07

Copyright © 1997, 2011, Oracle. All rights reserved.