Skip to content

Instantly share code, notes, and snippets.

Created April 21, 2015 20:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/245d0d726611cf4014e2 to your computer and use it in GitHub Desktop.
Save anonymous/245d0d726611cf4014e2 to your computer and use it in GitHub Desktop.
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