Skip to content

Instantly share code, notes, and snippets.

@cflove
Created March 24, 2024 22:57
Show Gist options
  • Save cflove/6736a117fab9e5c155fc583ab1a3965a to your computer and use it in GitHub Desktop.
Save cflove/6736a117fab9e5c155fc583ab1a3965a to your computer and use it in GitHub Desktop.
PostgreSQL isNull()
CREATE OR REPLACE FUNCTION isNull(value_to_check ANYELEMENT, replacement_value ANYELEMENT)
RETURNS ANYELEMENT AS $$
BEGIN
RETURN COALESCE(value_to_check, replacement_value);
END;
$$ LANGUAGE plpgsql IMMUTABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment