我已经设置了一个触发器,如下所示,但似乎发生了一些错误:
create or replace function insert_ft()
returns trigger as
$$
begin
if ((select "WeekDay", "Time", sec."Quarter", sec."Year"
from "WeeklyMeeting" wm, "Section" sec
where wm."SectionID" = new."SectionID"
and wm."SectionID" = sec."SectionID")
intersect
(select "WeekDay", "Time", ft."Quarter", ft."Year"
from "WeeklyMeeting" wm, "FacultyTeaching" ft, "Section" sec
where sec."SectionID" = ft."SectionID"
and ft."Quarter" = new."Quarter"
and ft."Year" = new."Year"
and ft."SectionID" = wm."SectionID"
and "Name" = new."Name")) is not null
then raise exception 'The Professor % has already taught a section %
at % on %',
new."Name", new."SectionID", (select "WeekDay" from "WeeklyMeeting"
where "SectionID" = new."SectionID"), (select "Time" from "WeeklyMeeting"
where "SectionID" = new."SectionID");
else
raise notice 'Adding Success';
return new;
end if;
end;
$$
language plpgsql;
create trigger "insert_constraint_ft"
before insert on "FacultyTeaching"
for each row execute procedure insert_ft();
错误显示为
ERROR: subquery must return only one column
LINE 1: SELECT ((select "WeekDay", "Time", sec."Quarter", sec."Year"...
有人可以帮我查看错误发生的地方吗?谢谢!