title: Postgres: test insert or update before doing it?
body: <p>We have a table that only ever contains one entry of a particular type, so if we get an request for an insert we delete everything and then do the insert. The insert comes from user data and there have been times where it throws an error (maybe they didn't fill something in, etc) and we end up with a bunch of deleted data. We are handling all the data processing so we don't have error like that anymore but I was wondering:</p>
  
  <p>Is there a way to test an insert or update to see if it will work before actually doing it?</p>