common db routine