Подзапрос триггера должен возвращать только один столбец в postgresql

Я настроил триггер следующим образом, но, похоже, возникает какая-то ошибка:

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"...

Может кто-нибудь помочь мне посмотреть, где происходит ошибка? Спасибо!

0 ответов

Другие вопросы по тегам