title: a transaction with a check if records already exist
body: <p>The code is here. Works OK but I just dont know how to write
  a transactions that would be more appropriate for the job (commit,rollback...).</p>
  
  <pre><code>procedure TForm1.cxButton1Click(Sender: TObject);
  begin
    with acrquery2 do
    begin
      ACRQuery1.DisableControls;
      SQL.Clear;
      SQL.Add('INSERT INTO dnevnik (datum,izmena_id,opravilo,narejeno,sprememba) SELECT :a1,izmena_id,opravilo,narejeno,sprememba FROM opravila where izmena_id = :a2');
      Params.ParamByName('a1').asdate := cxdateedit1.Date;
      Params.ParamByName('a2').AsInteger := acrtable1.FieldByName('izmena_id').AsInteger;
      ACRQuery2.ExecSQL;
      SQL.Clear;
      SQL.Add('UPDATE OPRAVILA SET NAREJENO=False,sprememba=null');
      ACRQuery2.ExecSQL;
      ACRQuery1.EnableControls;
      ACRQuery1.Refresh;
    end;
  </code></pre>
  
  <p>I would like to wrap the above code in a transaction but first do a check before insertion if "datum" and "izmena_id" already exist in the "dnevnik" table (duplicates are not allowed). If they do, then abort the operation with a message. I dont know the SQL for such a check. Probably 'if exists' ...</p>
  
  <p>In SQLite it was easy with setting constraints but dont know with Accuracer. Can someone help me write this code right ? Thank you !</p>