Handling Update Events
Go Up to Automating ER/Studio Data Architect
You can customize the Entity update template subroutines.
To enable this option, choose Tools > Options > Automation Options and then select Update Handlers.
You can customize templates for the following objects:
|
|
When you edit an entity with the Entity Editor, ER/Studio Data Architect immediately calls your UpdateEntityHandler function in the ERSUpdateHandlers.bas file.
The function is called, ER/Studio Data Architect passes the entity object as the first parameter, the diagram object as the second parameter, and the UpdateType as the third parameter. This distinguishes which property has been updated. The body of the function in the file contains empty case statements for the different entity properties. These empty statements do nothing. You can customize/extend the update behavior of any of the object's properties listed above by implementing the bodies of the property case statements in the function.
- ER/Studio Data Architect does not call the update event functions for entities until after you exit from the Entity Editor.
Example
Sub UpdateEntityHandler(CurEntity As Object, CurDiagram As Object, UpdateType As Integer)
Dim Prefix as String
Dim EntityName as String
Dim NewEntityName as String
Prefix = "ERS"
Select Case UpdateType
Case UPDENTITYNAME
EntityName = CurEntity.EntityName
NewEntityName = Prefix + EntityName
CurEntity.EntityName = NewEntityName
Case UPDENTITYTABLENAME
Case UPDENTITYDEFINITION
Case UPDENTITYNOTE
Case UPDENTITYPOSTSQL
Case UPDENTITYPRESQL
Case UPDENTITYSTORAGELOCATION
Case UPDENTITYINITIALEXTENT
Case UPDENTITYPCTFREE
Case UPDENTITYNOLOGGING
Case UPDENTITYPCTINCREASE
Case UPDENTITYNEXTEXTENT
Case UPDENTITYPCTUSED
End Select
End Sub
In this example, the UpdateEntityHandler function is modified so that a prefix of ERS is attached to the entity name each time you change the entity name.
Here is a more detailed explanation. When you edit the entity name and change it to Entity1, you also automatically add a prefix to the name. By modifying the case statement in the body of the UpdateEntityHandler function in the manner shown above, the entity name becomes ERSEntity1.
Notes
- When ER/Studio Data Architect starts, it reads in all the update event handler functions from the file ERSUpdateHandlers.bas. Modifications to these functions while the application is running have no effect. You must restart ER/Studio Data Architect for the modifications to take effect.
- A user cannot declare a specific object type (for example, Entity) in the update event handler functions. All objects must be declared as the generic Object type.