Skip to content

Commit

Permalink
Update createdb.sql
Browse files Browse the repository at this point in the history
Created isalum function that checks if a specified user is a alumni
  • Loading branch information
aaryauchamkeri authored Oct 11, 2024
1 parent 2814c36 commit 3c8b99b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions db-scripts/createdb.sql
Original file line number Diff line number Diff line change
Expand Up @@ -264,3 +264,16 @@ returns null on null input;
--$$ language plpgsql
--stable
--returns null on null input;

-- alum function that takes in the parameter of the user to check
CREATE OR REPLACE FUNCTION isalum(personId integer) RETURNS BOOLEAN LANGUAGE plpgsql AS
$$
DECLARE
gradDate date;
cDate date;
BEGIN
SELECT users.grad_date FROM users WHERE users.id = personId INTO gradDate;
SELECT CURRENT_DATE INTO cDate;
RETURN gradDate >= cDate;
END;
$$;

0 comments on commit 3c8b99b

Please sign in to comment.