Created
April 21, 2015 20:20
-
-
Save anonymous/245d0d726611cf4014e2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create table if not exists audit( | |
id serial, | |
hi varchar | |
); | |
create table if not exists trigger_tbl( | |
id serial, | |
log_text varchar | |
); | |
insert into audit(hi) values ('hi'); | |
-- | |
drop trigger holiday_trigger on audit; | |
drop function if exists checkday(); | |
create or replace function checkday() | |
returns trigger as | |
$$ | |
begin | |
if (select extract(dow from current_date)) in (6,0) then | |
raise exception 'it is holiday'; | |
end if; | |
return new; | |
end; | |
$$ language plpgsql; | |
create TRIGGER holiday_trigger before insert or Delete or update on audit | |
for each row execute procedure checkday(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment