title: Avoid duplicate rows in phonegap database
body: <p>I have a database with a single column and create it like this</p>
  
  <pre><code>function populateDB(tx){
     tx.executeSql('CREATE TABLE IF NOT EXISTS RESULT(result, UNIQUE(result))');  
  }
  </code></pre>
  
  <p>however, when I want to write objects into the table, I get the error:</p>
  
  <blockquote>
    <p>could not execute statement (19 constraint failed)</p>
  </blockquote>
  
  <p>The error only appears when I add the NOT NULL and PRIMARY KEY to the set-Up. Without it, it keeps writing duplicates in my database (I fill the database with data from a webservice on startup of a phonegap iOS application, so I want to catch duplicate rows on database level)</p>
  
  <p>At first I had only "PRIMARY KEY" in it, and because the error says something about constraints, I was assuming the primary key has to be "NOT NULL", adding it to the code, I still got the same error. </p>
  
  <p>how can I solve this. thanks in advance</p>
  
  <p><strong>edit</strong>: Maybe it´s important for you to know that I write stringyfied JSON Objects into the results column. </p>
  
  <p><strong>edit</strong>: I insert the object in this function. Basically I do it one by one:</p>
  
  <pre><code>this.save = function(){
      db.transaction (function(transaction){
          object = $.toJSON(self);
          object = encodeURI(object);
          transaction.executeSql('INSERT INTO RESULT (result) VALUES ("'+object+'")');
          },
          errorCB, 
          successCB
      );
  }
  </code></pre>
  
  <p><strong>edit</strong>: I updated my set up table code. The error doesnt occur on every row, but the objects are actually unique. </p>