Sha256: cc499c31998f778e5cabd2e3a84f35f99522f8f01d393762ae25b363e65d8314

Contents?: true

Size: 562 Bytes

Versions: 15

Compression:

Stored size: 562 Bytes

Contents

CREATE OR REPLACE FUNCTION update_pathology_observations_nresult_from_trigger() RETURNS TRIGGER AS $body$
DECLARE
BEGIN
  IF (TG_OP = 'INSERT' OR TG_OP = 'UPDATE') THEN
    NEW.nresult = convert_to_float(NEW.result, NULL);
  END IF;
  RETURN NEW ;
END $body$ LANGUAGE plpgsql;

COMMENT ON FUNCTION update_pathology_observations_nresult_from_trigger() IS
'Tries to coerce the result column into the nresult column as a float.
Sets nresult to NULL if result is eg text and cannot be coerced.
nresult is a performance optimisation useful for instance in graphing';

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
renalware-core-2.1.1 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.1.0 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.167 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.166 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.165 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.164 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.163 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.162 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.161 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.160 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.159 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.158 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.157 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.156 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql
renalware-core-2.0.155 db/functions/update_pathology_observations_nresult_from_trigger_v01.sql