title: Insert or update record in HighScore table
body: <p>I have a table that receives high score entries. However, if the user already has an entry in the table (tracked through a GUID field, not the user parameter) I want to update it if the new entry has a better time otherwise don't change the existing record. However, if the user doesn't have a record in the high score table then add a new record. I also have two query parameters to pass to the query.</p>
  
  <p>I want the insert operation to handle this for the table.  I have this so far but I get an exception raised when I call InsertAsync(...) on the highscore table</p>
  
  <pre><code>function insert(item, user, request) {
      var sql ="select Id from HighScore where PlayerGUID=? AND PlayerBadge=?";
      mssql.query(sql, [user.PlayerGUID], [user.PlayerBadge], {
          success: function(results) {
              if(results.length &gt; 0) {
                  // leader board record exists so update the current record
                  // Check the existing record and update it is the new time is better
                  console.log("Found existing entry");
              } else {
                  // no record exists for this user to insert one
                  request.execute();
                  console.log("Found existing entry");
              }
          }
      });
  }
  </code></pre>
  
  <p>Can anyone offer me any assistance with achieving my goal?</p>
  
  <p>Many thanks,</p>
  
  <p>J.</p>