maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ot_rw_mark_client_alerts(integer, timestamp with time zone, timestamp with time zone)
Parameters
Name
Type
Mode
_idclient
integer
IN
_start_date
timestamp with time zone
IN
_end_date
timestamp with time zone
IN
Definition
/* v20181105-RRB-To mark the alerts of a client as viewed. Using a separate CTE seems to be faster than an UPDATE alone. */ WITH q AS (SELECT a.idalert FROM alert a JOIN device d ON d.iddevice = a.iddevice JOIN technicalaccount ta ON ta.idtechnicalaccount = d.idtechnicalaccount WHERE ta.idclient = _idclient AND a.alertdate >= _start_date AND a.alertdate < _end_date and a.enabled = true), Q1 AS (UPDATE alert a SET enabled = false FROM q WHERE a.idalert = q.idalert AND a.alertdate >= _start_date AND a.alertdate < _end_date RETURNING a.idalert) SELECT count(*) FROM q1;