-- Wyzwalacz do normalizacji kolumny ochrona.

create or replace function f3 () returns trigger as $$
begin
  if (new.ochrona = 't') then
    new.ochrona := 'tak';
  elsif (new.ochrona = 'n') then
    new.ochrona := 'nie';
  end if;
  raise notice 'Tu jestem';
  if (new.ochrona in ('tak','nie') or new.ochrona is null) then
    return new;
  else
    raise exception 'Ochrona';
  end if;
end;
$$ language plpgsql;

create trigger t3 before insert or update
 on gatunki for each row
 execute procedure f3();

