Page tree
Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 5 Next »

In order to add support for custom database triggers you need to do the following:


Extend the DatabaseTriggerLoadService class


This new class will be used to dynamically load the specified database triggers.

Akioma.Swat.Server.Startup.DatabaseTriggerLoadService is a SWAT class which implements the IDatabaseTriggerLoadService interface. You can specify the triggers to load in the LoadTriggers method of the class.
It is recommended to extend the existing SWAT implementation instead of writing a new implementation for the interface, since triggers may also be loaded from SWAT.


The new class implementation will look similar to this:

Custom Database Trigger Example
USING Progress.Lang.*.

BLOCK-LEVEL ON ERROR UNDO, THROW.

CLASS Custom.CustomDatabaseTriggerLoadService
  INHERITS Akioma.Swat.Server.Startup.DatabaseTriggerLoadService:	//inherits the existing SWAT implementation

  METHOD PUBLIC OVERRIDE VOID LoadTriggers():
    SUPER:LoadTriggers().	//calls super in case triggers are loaded from SWAT
    
    RUN loadCustomTriggers.p. // procedure to include custom triggers
  END METHOD.
END CLASS.

Override the existing IDatabaseTriggerLoadService service

In order to make use of this new class, we will need to override the default trigger load service in the services.xml file by including the following:

Override Default Trigger Load Service
<ttServiceLoaderRow>
    <Order>0</Order>
    <ServiceTypeName>Akioma.Swat.Server.Startup.IDatabaseTriggerLoadService</ServiceTypeName>
    <ServiceClassName>Custom.CustomDatabaseTriggerLoadService</ServiceClassName>
</ttServiceLoaderRow>

Load the custom triggers

In the above example, we run loadCustomTriggers.p from the LoadTriggers method. A simple implementation of the procedure will look like this:

loadCustomTriggers.p
{Custom/Triggers/myCreateTrigger.i}	//here, we just include the desired triggers


And inside the trigger itself:

myCreateTrigger.i
ON CREATE OF myTable
DO:
  MESSAGE "Created new record".
END.




  • No labels