-
Notifications
You must be signed in to change notification settings - Fork 0
/
Procedures.sql
85 lines (78 loc) · 1.82 KB
/
Procedures.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
USE heroku_efc788d1dc18da4;
DELIMITER $$
USE heroku_efc788d1dc18da4 $$
CREATE PROCEDURE SelectClinicIDFromCity (
IN I int,
IN C varchar(255)
)
BEGIN
SELECT c.ID
FROM VACCINE v JOIN VACCINE_SUPPORT s ON v.ID = s.VID JOIN CLINIC c ON c.ID = s.CID
WHERE v.ID = I AND c.City = C;
END
$$
DELIMITER //
USE heroku_efc788d1dc18da4 //
CREATE PROCEDURE UpdateVaccine (
IN N varchar(255),
IN A varchar(255),
IN D varchar(255),
IN U varchar(255),
IN I int
)
BEGIN
UPDATE VACCINE
SET Name = N, Advisery = A, Description = D, URL = U
WHERE ID = I;
END
//
DELIMITER !!
USE heroku_efc788d1dc18da4 !!
CREATE PROCEDURE GetAppointments (
IN I int
)
BEGIN
SELECT r.ID, v.Name as VName, c.Name as CName, a.Date, a.Status
FROM APPOINTMENT a JOIN REQUEST_APPOINTMENT r ON a.RID = r.ID JOIN CLINIC c ON c.ID = a.CID JOIN VACCINE v ON v.ID = r.VID
WHERE r.PID = I;
END
!!
DELIMITER ;;
USE heroku_efc788d1dc18da4 ;;
CREATE PROCEDURE GetPatientIDFromRequestID (
IN I int
)
BEGIN
SELECT r.PID
FROM APPOINTMENT a JOIN REQUEST_APPOINTMENT r ON a.RID = r.ID
WHERE a.RID = I;
END
;;
DELIMITER %%
USE heroku_efc788d1dc18da4 %%
CREATE PROCEDURE UpdateAppointment (
IN S varchar(255),
IN I int
)
BEGIN
UPDATE APPOINTMENT
SET Status = S
WHERE RID = I;
END
%%
DELIMITER **
USE heroku_efc788d1dc18da4 **
CREATE PROCEDURE GetAllScores()
BEGIN
SELECT u.FName, u.MName, u.LName, p.Age, h.HealthNumber
FROM USER u JOIN PATIENT p ON u.ID = p.ID JOIN HEALTH_PROFILE h ON p.ID = h.ID;
END
**
DELIMITER ++
USE heroku_efc788d1dc18da4 ++
CREATE PROCEDURE GetAllAppointments ()
BEGIN
SELECT u.ID, u.FName, u.MName, u.LName, v.Name as VName, c.Name as CName, a.Date, a.Status
FROM APPOINTMENT a JOIN REQUEST_APPOINTMENT r ON a.RID = r.ID JOIN CLINIC c ON c.ID = a.CID JOIN VACCINE v ON v.ID = r.VID JOIN USER u ON u.ID = r.PID;
END
++