Guest User

Untitled

a guest
Jul 18th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.10 KB | None | 0 0
  1. Table: user( name, last_name, age, ..., sync_status )
  2. IF (TG_OP = 'UPDATE' ) then
  3.  
  4. if new.sync_status != syncstatus_pending then
  5. if old.sync_status = syncstatus_pending and new.sync_status != old.sync_status then
  6. raise notice 'Sync status updated, It means we are changing from sync pending to sync yes';
  7. return new ;
  8. else
  9. raise Exception 'The synchronization status is not configured correctly.' ;
  10. end if ;
  11. end if;
  12. -- Check if we are trying to update a not synchronized row
  13. if old.sync_status != syncstatus_yes then
  14. raise Exception 'It was not possible to update rows are not synchronized.';
  15. end if ;
  16. if new.name = old.name and new.last_name = old.last_name and new.age = old.age
  17. and old.sync_status= syncstatus_yes and new.sync_status= syncstatus_pending then
  18. -- all columns are the same except the sync one, it means that we require sync this row but not to add to log_table
  19. return new;
  20. else
  21. -- process to insert in the other 'log' table
  22. -- ...
  23. insert into log_table ( )
  24. end if ;
  25. end if ;
Add Comment
Please, Sign In to add comment