maya
.public
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
ot_rw_update_georeference(integer, real, real, timestamp with time zone)
Parameters
Name
Type
Mode
in_idunit
integer
IN
in_longitude
real
IN
in_latitude
real
IN
in_senddate
timestamp with time zone
IN
Definition
DECLARE _current_geofences int[]; _idclient int; _result geofence_history%ROWTYPE; _shippers int[]; _idshipper int; BEGIN SELECT idclient INTO _idclient FROM unit WHERE idunit = in_idunit; SELECT array_agg(idclientshipper) INTO _shippers FROM shipperconf WHERE idclientowner = _idclient; SELECT array_agg(g) INTO _current_geofences FROM omni_ro_get_current_geofence(_idclient,in_longitude,in_latitude) g; IF _shippers IS NOT NULL THEN FOREACH _idshipper IN ARRAY _shippers LOOP SELECT array_cat(array_agg(g),_current_geofences) INTO _current_geofences FROM omni_ro_get_current_geofence(_idshipper,in_longitude,in_latitude ) g; END LOOP; END IF; select g.* into _result from ot_rw_insert_geofence_history(in_idunit,_current_geofences,in_senddate) g; PERFORM ot_rw_update_current_geofence(in_idunit,array_to_string(_current_geofences,',')); RETURN QUERY (SELECT _result.*); END;