Correction to sql for create and update device errors.  #164