1
我嘗試做一個觸發功能,將檢查是否在插入/事件日期的記錄的更新的信息是有效的:觸發功能
create or replace function trigf() returns trigger as $$
declare bad_date record;
begin
select festival.title into bad_date
from festival
where new.title = festival.title and (new.edate < festival.sdate or new.edate > festival.edate);
if exists bad_date then
raise notice 'Error: Event Date does not Correlate with the Festival.';
if T = 'insert' then return null;
else return old;
end if;
else
return new;
end if;
end;
$$language plpgsql;
create trigger T
before insert or update on event
for each row
execute procedure trigf();
編譯通過罰款,但試圖插入值時,我得到bad_date不存在的錯誤。我想誰並欣賞熱門知道任何人去修補,而不是它