-
-
Save dxdinh/c398329e318cb22e3124b3ea20846fcb to your computer and use it in GitHub Desktop.
passwd function for my article
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 FUNCTION passwd_func() | |
RETURNS TRIGGER | |
AS $$ | |
BEGIN | |
IF length(NEW.password) < 10 OR NEW.password IS NULL THEN | |
RAISE EXCEPTION 'password cannot be less than 10 characters'; | |
END IF; | |
IF NEW.NAME IS NULL THEN | |
RAISE EXCEPTION 'Name cannot be NULL'; | |
END IF; | |
RETURN NEW; | |
END; | |
$$ | |
LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment