state VARCHAR NOT NULL CHECK (state in ('no_agreement', 'pending',
8
'enabled', 'disabled')),
8
'enabled', 'disabled'))
9
DEFAULT 'no_agreement',
9
10
rolenm VARCHAR NOT NULL CHECK (rolenm in ('anyone', 'student',
10
11
'marker', 'tutor',
11
12
'lecturer', 'admin')),
97
98
oid INTEGER;
98
99
BEGIN
99
100
SELECT offeringid INTO oid FROM project_set WHERE project_set.projectsetid = NEW.projectsetid;
100
PERFORM 1 FROM project_group, project_set WHERE project_group.projectsetid = project_set.projectsetid AND project_group.groupnm = NEW.groupnm;
101
PERFORM 1 FROM project_group, project_set WHERE project_set.offeringid = oid AND project_group.projectsetid = project_set.projectsetid AND project_group.groupnm = NEW.groupnm;
101
102
IF found THEN
102
103
RAISE EXCEPTION ''a project group named % already exists in offering ID %'', NEW.groupnm, oid;