Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Apress
committed
Oct 16, 2016
0 parents
commit e0565e2
Showing
39 changed files
with
17,308 additions
and
0 deletions.
There are no files selected for viewing
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
-- Create Users Table | ||
CREATE TABLE tusers | ||
( | ||
user_id NUMBER (5, 0) PRIMARY KEY, | ||
user_name VARCHAR2 (10) NOT NULL UNIQUE, | ||
password VARCHAR2 (10) NOT NULL, | ||
active_flag VARCHAR2 (1) NOT NULL | ||
); | ||
|
||
-- Create sequence for IDs | ||
CREATE SEQUENCE sn_users; | ||
|
||
-- Create Users | ||
-- Note: You should not store passwords in clear text. | ||
-- This was done for demonstration purposes. | ||
INSERT INTO tusers ( user_id, user_name, password, active_flag) | ||
VALUES (sn_users.NEXTVAL, 'martin', 'martin', 'Y'); | ||
|
||
INSERT INTO tusers ( user_id, user_name, password, active_flag) | ||
VALUES (sn_users.NEXTVAL, 'chris', 'chris', 'Y'); | ||
|
||
INSERT INTO tusers ( user_id, user_name, password, active_flag) | ||
VALUES (sn_users.NEXTVAL, 'cameron', 'cameron', 'Y'); | ||
|
||
-- Authentication Function | ||
CREATE OR REPLACE FUNCTION f_login (p_username IN VARCHAR2, p_password IN VARCHAR2) | ||
RETURN BOOLEAN | ||
AS | ||
v_count PLS_INTEGER; | ||
BEGIN | ||
SELECT COUNT (user_id) | ||
INTO v_count | ||
FROM tusers | ||
WHERE LOWER (user_name) = LOWER (p_username) | ||
AND password = password | ||
AND active_flag = 'Y'; | ||
|
||
IF v_count = 1 THEN | ||
RETURN TRUE; | ||
END IF; | ||
|
||
RETURN FALSE; | ||
END f_login; | ||
/ | ||
|
||
COMMIT; |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.