SAP HANA
Simple Trigger mechanism example on HANA to do run time Analytics.
Step1. First create two tables: |
1. | City contains (location id, city name, country, population) fields. |
2. | Country contains (Country, population) fields. |
Step2. Create a procedure which first delete all the entries of country table and then update country table with the sum of population |
CREATE PROCEDURE "P1634712998".TESTPR04
( ) as
begin
DELETE FROM "P1634712998"."COUNTRY";
SELECT "COUNTRY" , SUM("POPULATION")
from "P1634712998"."CITY" GROUP BY "COUNTRY" INTO "P1634712998"."COUNTRY";
end ;
Step3. Create a trigger and call the procedure in the trigger. Trigger fires each time when data is insert into city table its automatic update country table. |
CREATE TRIGGER "P1634712998".demo1
AFTER INSERT On "P1634712998"."CITY"
REFERENCING NEW ROW NEW for each row
BEGIN
CALL "P1634712998"."TESTPR04";
END;
Now each time when you insert data into city table country table will automatically update countries wise with sum of population.