database writing operation macro