Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Table: user( name, last_name, age, ..., sync_status )
- IF (TG_OP = 'UPDATE' ) then
- if new.sync_status != syncstatus_pending then
- if old.sync_status = syncstatus_pending and new.sync_status != old.sync_status then
- raise notice 'Sync status updated, It means we are changing from sync pending to sync yes';
- return new ;
- else
- raise Exception 'The synchronization status is not configured correctly.' ;
- end if ;
- end if;
- -- Check if we are trying to update a not synchronized row
- if old.sync_status != syncstatus_yes then
- raise Exception 'It was not possible to update rows are not synchronized.';
- end if ;
- if new.name = old.name and new.last_name = old.last_name and new.age = old.age
- and old.sync_status= syncstatus_yes and new.sync_status= syncstatus_pending then
- -- all columns are the same except the sync one, it means that we require sync this row but not to add to log_table
- return new;
- else
- -- process to insert in the other 'log' table
- -- ...
- insert into log_table ( )
- end if ;
- end if ;
Add Comment
Please, Sign In to add comment