Skip to content

Instantly share code, notes, and snippets.

@seifip
Created June 3, 2020 06:46
Show Gist options
  • Save seifip/a172fa352352eab740913c63c443c2f3 to your computer and use it in GitHub Desktop.
Save seifip/a172fa352352eab740913c63c443c2f3 to your computer and use it in GitHub Desktop.
CREATE OR REPLACE FUNCTION test_float()
RETURNS float AS $$
DECLARE
price float = 0.0;
BEGIN
WHILE price < 10.0 LOOP
price = price + 0.1;
END LOOP;
RETURN price;
END;
$$ LANGUAGE plpgsql;
SELECT test_float();
-- test_float
-- ---------------------
-- 10.09999999999998
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment