39 lines
1.5 KiB
Go
39 lines
1.5 KiB
Go
|
|
// Package sql defines reusable database SQL statements
|
||
|
|
package sql
|
||
|
|
|
||
|
|
const (
|
||
|
|
// MeasurementInitializationRows joins measurements to the hierarchy used by
|
||
|
|
// all supported data-object token forms. The bay join guarantees that
|
||
|
|
// token6=bay refers to an existing bay record.
|
||
|
|
MeasurementInitializationRows = `SELECT
|
||
|
|
grid.tagname AS grid_tag,
|
||
|
|
zone.tagname AS zone_tag,
|
||
|
|
station.tagname AS station_tag,
|
||
|
|
component.global_uuid::text AS component_uuid,
|
||
|
|
component.nspath AS component_nspath,
|
||
|
|
component.tag AS component_tag,
|
||
|
|
measurement.id AS measurement_id,
|
||
|
|
measurement.tag AS measurement_tag,
|
||
|
|
measurement.name AS measurement_name,
|
||
|
|
measurement.type AS measurement_type,
|
||
|
|
measurement.mode AS measurement_mode,
|
||
|
|
measurement.size AS measurement_size,
|
||
|
|
measurement.data_source AS measurement_data_source,
|
||
|
|
measurement.event_plan AS measurement_event_plan,
|
||
|
|
measurement.binding AS measurement_binding
|
||
|
|
FROM public.grid AS grid
|
||
|
|
INNER JOIN public.zone AS zone ON zone.grid_id = grid.id
|
||
|
|
INNER JOIN public.station AS station ON station.zone_id = zone.id
|
||
|
|
INNER JOIN public.component AS component ON component.station_id = station.id
|
||
|
|
INNER JOIN public.measurement AS measurement
|
||
|
|
ON measurement.component_uuid = component.global_uuid
|
||
|
|
INNER JOIN public.bay AS bay
|
||
|
|
ON bay.bay_uuid = measurement.bay_uuid
|
||
|
|
WHERE grid.tagname <> ''
|
||
|
|
AND zone.tagname <> ''
|
||
|
|
AND station.tagname <> ''
|
||
|
|
AND component.nspath <> ''
|
||
|
|
AND component.tag <> ''
|
||
|
|
AND measurement.tag <> ''`
|
||
|
|
)
|