Skip to content

Instantly share code, notes, and snippets.

@Samuyi
Created January 8, 2019 16:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Samuyi/42c7ec34248825cc66fc71a671202365 to your computer and use it in GitHub Desktop.
Save Samuyi/42c7ec34248825cc66fc71a671202365 to your computer and use it in GitHub Desktop.
passwd function for my article
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