updated demo code to show the use of db transaction and template macro