diff --git a/migrations/20210822052026_isnumeric_function.down.sql b/migrations/20210822052026_isnumeric_function.down.sql new file mode 100644 index 0000000..ea1e4a0 --- /dev/null +++ b/migrations/20210822052026_isnumeric_function.down.sql @@ -0,0 +1 @@ +DROP FUNCTION IF EXISTS isnumeric; diff --git a/migrations/20210822052026_isnumeric_function.up.sql b/migrations/20210822052026_isnumeric_function.up.sql new file mode 100644 index 0000000..cb0e2a6 --- /dev/null +++ b/migrations/20210822052026_isnumeric_function.up.sql @@ -0,0 +1,11 @@ +CREATE OR REPLACE FUNCTION isnumeric(text) RETURNS BOOLEAN AS $$ +DECLARE x NUMERIC; +BEGIN + x = $1::NUMERIC; + RETURN TRUE; +EXCEPTION WHEN others THEN + RETURN FALSE; +END; +$$ +STRICT +LANGUAGE plpgsql IMMUTABLE;