daily pastebin goal
39%
SHARE
TWEET

Untitled

a guest May 7th, 2016 56 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. DELIMITER $$
  2. CREATE DEFINER=`root`@`localhost` PROCEDURE `login`(IN usr VARCHAR(16),IN pwd VARCHAR(40))
  3.     LANGUAGE SQL
  4.     NOT DETERMINISTIC
  5.     CONTAINS SQL
  6.     SQL SECURITY DEFINER
  7.     COMMENT ''
  8.     READS SQL DATA
  9. BEGIN
  10.     DECLARE l_staff_id TINYINT(3);
  11.     DECLARE l_usr VARCHAR(16);
  12.     DECLARE l_usr_no_pwd VARCHAR(16);
  13.    
  14.     SELECT staff_id FROM staff WHERE username = usr INTO l_staff_id;
  15.     SELECT username FROM staff WHERE password = pwd AND username = usr INTO l_usr;
  16.     SELECT username FROM staff WHERE password IS NULL AND username = usr INTO l_usr_no_pwd;
  17.    
  18.     IF l_staff_id IS NULL
  19.     THEN INSERT INTO LoginHistory(staff_id, date_time, is_success) VALUES (1, NOW(), 0);
  20.     ELSEIF l_usr IS NULL AND l_usr_no_pwd
  21.     THEN INSERT INTO LoginHistory(staff_id, date_time, is_success) VALUES (l_staff_id, NOW(), 0);
  22.     ELSEIF l_usr IS NOT NULL
  23.     THEN INSERT INTO LoginHistory(staff_id, date_time, is_success) VALUES (l_staff_id, NOW(), 1);
  24.     ELSEIF l_usr_no_pwd IS NOT NULL
  25.     THEN IF l_pwd = ""
  26.         THEN INSERT INTO LoginHistory(staff_id, date_time, is_success) VALUES (l_staff_id, NOW(), 1);
  27.         ELSEIF l_pwd != ""
  28.         THEN INSERT INTO LoginHistory(staff_id, date_time, is_success) VALUES (l_staff_id, NOW(), 0);
  29.         END IF;
  30.     END IF;
  31. END;
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top