You can extend script generation statements to complement generation using the extension statements. The extension mechanism allows you to generate statements immediately before or after Create, Drop, and Modify statements, and to retrieve these statements during reverse engineering.
Extension statements are written in GTL (see Customizing Generation with GTL). During generation, the statements and variables are evaluated and the result is added to the global script.
.if (%ExtTablePartition% > 1) %CreatePartition% go .endif
alter table [%QUALIFIER%]%TABLE% partition %ExtTablePartition%
This item generates the statement for creating the number of table partitions specified in %ExtTablePartition%.
The extension statement BeforeCreate is defined in the User category to create the login of a user before the user Create statement is executed:
sp_addlogin %Name% %Password% go
The automatically generated login will have the same name as the user, and its password. The BeforeCreate statement is displayed before the user creation statement in the Preview:
You can also add BeforeModify and AfterModify statements to standard Modify statements.
Modify statements are executed to synchronize the database with the schema created in the PDM. By default, the modify database feature does not take into account extended attributes when it compares changes performed in the model from the last generation. You can bypass this rule by adding extended attributes in the ModifiableAttributes list item. Extended attributes defined in this list will be taken into account in the merge dialog box during database synchronization.
For example, you can verify that the value of the extended attribute ExtTablePartition has been modified using the following GTL syntax:
.if (%OLDOBJECT.ExtTablePartition% != %NEWOBJECT.ExtTablePartition%)
If the extended attribute value was changed, an extended statement will be generated to update the database. In the Sybase ASE syntax, the ModifyPartition extended statement is the following because in case of partition change you need to delete the previous partition and then recreate it:
.if (%OLDOBJECT.ExtTablePartition% != %NEWOBJECT.ExtTablePartition%) .if (%NEWOBJECT.ExtTablePartition% > 1) .if (%OLDOBJECT.ExtTablePartition% > 1) %DropPartition% .endif %CreatePartition% .else %DropPartition% .endif .endif