Charting Non-Live Data

<< Click to Display Table of Contents >>

Charting Non-Live Data

The following SQL function may be used to chart DT_MEASURE_DATUM data in the Live Historical Chart widget:

 

 

IF OBJECT_ID(N'[equis].[fn_get_measure_datum]') IS NOT NULL

DROP FUNCTION [equis].[fn_get_measure_datum];

GO

 

CREATE FUNCTION [equis].[fn_get_measure_datum]

(

 @logger_series_id INT

,@start_date DATETIME

)

RETURNS @data TABLE

(

 datum_utc_dt DATETIME

,datum_value REAL

)

AS

BEGIN

DECLARE @facility_id INT;

DECLARE @sys_loc_code VARCHAR(20);

 

-- Get the series' facility_id and sys_loc_code.

SELECT

   @facility_id = facility_id

  ,@sys_loc_code = sys_loc_code

FROM

   dt_logger_series

WHERE

   logger_series_id = @logger_series_id;

 

-- @data = dt_measure_datum.start_dates and datum_values.

INSERT INTO

   @data

SELECT

  start_date

  ,datum_value

FROM

   dt_measure_datum

WHERE

  start_date >= @start_date

  AND facility_id = @facility_id

  AND sys_loc_code = @sys_loc_code

ORDER BY

  start_date ASC;

 

RETURN

END

GO