maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ot_rw_alert_last_tg()
Parameters
Name
Type
Mode
Definition
DECLARE BEGIN /* To maintain a materialized view called alert_last that stores the last */ WITH Q AS (UPDATE alert_last SET idalert = NEW.idalert, relevantinfo = NEW.relevantinfo, enabled = NEW.enabled, active = NEW.active, alertdate = NEW.alertdate, creationdate = NEW.creationdate, additionalinfo = NEW.additionalinfo WHERE alert_type = NEW.alert_type AND idalertconf = NEW.idalertconf AND iddevice = NEW.iddevice RETURNING * ) INSERT INTO alert_last (idalert,relevantinfo,enabled,active,alert_type,idalertconf,alertdate,iddevice,creationdate,additionalinfo,latitude,longitude,odometer,location,speed) SELECT NEW.idalert, NEW.relevantinfo, NEW.enabled, NEW.active, NEW.alert_type, NEW.idalertconf, NEW.alertdate, NEW.iddevice, NEW.creationdate, NEW.additionalinfo, NEW.latitude, NEW.longitude, NEW.odometer, NEW.location, NEW.speed WHERE NOT EXISTS (SELECT 1 FROM Q); RETURN NEW; EXCEPTION WHEN OTHERS THEN RETURN NEW; END