Advertisement
Pandaaaa906

Untitled

Aug 12th, 2022
817
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION "chemhost"."normalize_package"(text)
  2.   RETURNS "pg_catalog"."float8" AS $BODY$
  3. select CASE lower(COALESCE(substring($1, '([muμMKk]?[GLgl])$'::text), 'mg'::text))
  4.     WHEN 'g'::text THEN (1000)::numeric
  5.     WHEN 'mg'::text THEN (1)::numeric
  6.     WHEN 'ml'::text THEN (1000)::numeric
  7.     WHEN 'l'::text THEN (1000000)::numeric
  8.     WHEN 'kg'::text THEN (1000000)::numeric
  9.     WHEN 'ug'::text THEN 0.001
  10.     WHEN 'μg'::text THEN 0.001
  11.     WHEN 'μl'::text THEN (1)::numeric
  12.     WHEN 'ul'::text THEN (1)::numeric
  13.     ELSE NULL::numeric
  14.     END * COALESCE((substring($1, '(\d+(\.\d+)?)\s?[muμMKk]?[GLgl]'::text))::double precision, NULL::double precision);
  15.        
  16.         $BODY$
  17.   LANGUAGE sql IMMUTABLE STRICT
  18.   COST 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement