Skip to content

Instantly share code, notes, and snippets.

@jheidt
Forked from xenoterracide/empty.sql
Created October 26, 2015 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jheidt/32df7bf593bbb9b0b2bd to your computer and use it in GitHub Desktop.
Save jheidt/32df7bf593bbb9b0b2bd to your computer and use it in GitHub Desktop.
Find empty strings or strings containing only whitespace, for postgresql
CREATE OR REPLACE FUNCTION empty(TEXT)
RETURNS bool AS
$$ SELECT $1 ~ '^[[:space:]]*$'; $$
LANGUAGE sql
IMMUTABLE;
COMMENT ON FUNCTION empty(TEXT)
IS 'Find empty strings or strings containing only whitespace';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment