Created
March 24, 2024 22:57
-
-
Save cflove/6736a117fab9e5c155fc583ab1a3965a to your computer and use it in GitHub Desktop.
PostgreSQL isNull()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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