Update functions.sql

Add o2p auto update functionality back in