Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE OR REPLACE FUNCTION "chemhost"."normalize_package"(text)
- RETURNS "pg_catalog"."float8" AS $BODY$
- select CASE lower(COALESCE(substring($1, '([muμMKk]?[GLgl])$'::text), 'mg'::text))
- WHEN 'g'::text THEN (1000)::numeric
- WHEN 'mg'::text THEN (1)::numeric
- WHEN 'ml'::text THEN (1000)::numeric
- WHEN 'l'::text THEN (1000000)::numeric
- WHEN 'kg'::text THEN (1000000)::numeric
- WHEN 'ug'::text THEN 0.001
- WHEN 'μg'::text THEN 0.001
- WHEN 'μl'::text THEN (1)::numeric
- WHEN 'ul'::text THEN (1)::numeric
- ELSE NULL::numeric
- END * COALESCE((substring($1, '(\d+(\.\d+)?)\s?[muμMKk]?[GLgl]'::text))::double precision, NULL::double precision);
- $BODY$
- LANGUAGE sql IMMUTABLE STRICT
- COST 100
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement