SQL/MX 2.x Installation and Management Guide (H06.10+, J06.03+)

Adding, Altering, and Dropping SQL/MX Database
Objects
HP NonStop SQL/MX Installation and Management Guide544536-007
9-16
Adding Triggers
9. Revise the application source code as needed to reflect your changes to the
database. Process and compile the updated source file. For more information, see
the SQL/MX Programming Manual for C and COBOL.
10. Perform a TMF online dump. For a partitioned table, perform an online dump of
each partition.
For more information and examples of adding a table, see Creating SQL/MX Tables on
page 7-11.
Adding Triggers
To add a trigger to an SQL/MX table, use the CREATE TRIGGER statement.
User applications that change (INSERT, UPDATE, or DELETE) information in a table
are automatically recompiled when a trigger with a matching event is added or
dropped. User applications that use a SELECT on the subject table do not require
recompilation. User applications require SQL recompilations only when triggers are
added, altered or dropped. No source code changes or language compilations are
required.
For more information, see the SQL/MX Reference Manual.
Steps for Adding a Trigger
1. Start an MXCI session. Enter a LOG command to initiate a log file for statements
and commands entered in this session. Keep the log for your records.
2. Determine the name of the table to which you want to add the trigger.
3. Query the system metadata to ensure the new trigger name is unique among
existing trigger names defined in the schema.
4. Use the DISPLAY USE OF command to identify which user modules are
associated with this object. See the similarity check criteria in the SQL/MX
Programming Manual for C and COBOL to determine if your changes are likely to
cause similarly check to fail and force automatic recompilation. If they will, you
should SQL compile these modules after making the changes to avoid expensive
automatic recompilations at run time. SQL applications that are running while you
make these changes will still undergo automatic recompilation.
For information about explicit and automatic recompilation, see the SQL/MX
Programming Manual for C and COBOL. For information about using DISPLAY
USE OF, see Checking Module Dependencies with DISPLAY USE OF on
page 11-19 and the SQL/MX Reference Manual.
5. Enter the CREATE TRIGGER statement.
6. Revise the application source code as needed to reflect your changes to the
database. Process and compile the updated source file. For more information, see
the SQL/MX Programming Manual for C and COBOL.