testdb=> create function log_change () returns trigger language plpgsql as $$ begin if new.balance <> old.balance then insert into log_change (account_id, change, datetime) values (old.id, new.balance - old.balance, now ());
testdb=> create function log_change () returns trigger language plpgsql as $$
begin
if new.balance <> old.balance then
insert into log_change (account_id, change, datetime)
values (old.id, new.balance - old.balance, now ());