Rules for creating triggers for custom tables
When you are adding SQL statements to create and drop triggers for custom tables, ensure that you follow the appropriate rules.
Trigger creation SQL file
Add SQL statements for creating triggers to the following files:
- WC_installdir/schema/db2/wcs.stage.trigger.sql
- WC_installdir/schema/oracle/wcs.stage.trigger.sql
Put the SQL statements for creating triggers for custom tables in these files.
Trigger dropping SQL file
Add SQL statements for dropping triggers to the following files:
- WC_installdir/schema/db2/wcs.droptrigger.sql
- WC_installdir/schema/oracle/wcs.droptrigger.sql
Put the SQL statements for dropping triggers for custom tables in these files.
Trigger naming convention
Trigger_naming_conventionThe trigger naming convention is a guideline to ensure that new triggers for custom tables have unique names.
WebSphere Commerce names a trigger by incrementing that last number of the last trigger in the db2/wcs.stage.trigger.sql file. Do not use this naming convention for your new triggers as your custom trigger names could conflict with any new triggers introduced by WebSphere Commerce in fix packs or later releases.
Ensure that the name of your new triggers follow the pattern found in the oracle/wcs.stage.trigger.sql file:
- Insert trigger: ISTG_ CustomTableName
- Update trigger: USTG_ CustomTableName
- Delete trigger: DSTG_ CustomTableName
Create trigger requirements
You must create three triggers for the custom database table:
- An INSERT trigger to capture insert operations on the custom table.
- An UPDATE trigger to capture update operation on the custom table.
- A DELETE trigger to capture delete operations on the custom table.
- For the value of the STAGLOG.STGRFNBR column, you are recommended to use the NEXTVAL FOR STAGESEQ function to generate the value. If you use a different counter, you might result in key collisions within the STAGLOG table.
- Use the STAGESEQ.NEXTVAL function to generate the STAGLOG.STGRFNBR column value. When you are inserting a value for the STAGLOG.STGSTMP column, use the function SYSDATE to generate the time stamp value. If you use other functions to generate this value, the generated value might not result in the appropriate data format that is expected by the staging utility. If the generated value is not in the appropriate data format, data might be omitted from the staging utility.
- For STAGLOG columns not defined directly within this table, use a value of NULL.