Skip to content

Instantly share code, notes, and snippets.

@garethflowers
Last active May 3, 2021 22:05
Show Gist options
  • Select an option

  • Save garethflowers/4974160 to your computer and use it in GitHub Desktop.

Select an option

Save garethflowers/4974160 to your computer and use it in GitHub Desktop.
Checks whether a value is a valid Numeric
CREATE OR REPLACE FUNCTION is_numeric(
ANYELEMENT
)
RETURNS BOOLEAN
LANGUAGE sql
IMMUTABLE
STRICT
AS $$
SELECT $1::TEXT ~ '^[-+]?[0-9]*[.]?[0-9]+$';
$$;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment