Advertisement
fahadkalil

plpgsql_funcao_staff_user_senha

Mar 25th, 2021
1,390
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE OR REPLACE FUNCTION public.get_id_funcionario(in_usuario VARCHAR, in_senha VARCHAR)
  2. RETURNS NUMERIC
  3. AS $$
  4. -- Declaracao de variavel
  5. DECLARE
  6.     id_funcionario INT := 0;
  7.  
  8. BEGIN
  9.     SELECT staff_id INTO id_funcionario
  10.     FROM staff
  11.     WHERE username = in_usuario AND password = in_senha;
  12.  
  13. RETURN id_funcionario;
  14.  
  15. EXCEPTION
  16.     WHEN no_data_found THEN
  17.         RAISE EXCEPTION 'Usuário ou Senha Inválida';       
  18. END;
  19. $$ LANGUAGE 'plpgsql';
  20.  
  21. select public.get_id_funcionario('Mike', '8cb2237d0679ca88db6464eac60da96345513964');
  22.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement