如何检查sqlite phonegap中列中的重复项目 [英] How to check duplicate item in column in sqlite phonegap

查看:107
本文介绍了如何检查sqlite phonegap中列中的重复项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在插入日期之前需要检查我表中的重复项。但是我在检查时遇到错误。这是我的代码。我需要检查元素是否已经存在然后返回false如果没有则返回true。并创建一个新的条目



函数validationField(){
db.transaction(getallTableCntend,errorCB);
}

函数getallTableCntend(tx){
tx.executeSql('SELECT * FROM CaseTable',[],queryexcecute,errorCB);
}
函数queryexcecute(tx,result){
var len = result.rows.length;

for(var i = 0; i< len; i ++){
if(result.rows.item(i).CaseName == $('。caseName_h')。val ()){
alert(文件夹已退出。);
isvalid = false;
休息;
return ;;
}
}
}





我这样称呼这个。

 $(文件).on('click','#AddButton',function(){
isvalid = validationField();
if(isvalid) ){
insertData();
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,onFileSystemSuccess,onFileSystemFail);
}
});

解决方案

('。caseName_h')。val()){
alert(文件夹已退出。);
isvalid = false;
休息;
return ;;
}
}
}





我这样称呼这个。

 


(document).on('click','#AddButton',function(){
isvalid = validationField ();
if(isvalid){
insertData();
window.requestFileSystem(LocalFileSystem.PERSISTENT,0,onFileSystemSuccess,onFileSystemFail);
}
}) ;


need to check duplicate item in my table before insert date .But i am getting error while checking.Here is my code.I need to check whether the element already exist then return false If not then return true.And create a new entry

function validationField() {
     db.transaction(getallTableCntend, errorCB);
   }

   function getallTableCntend(tx) {
       tx.executeSql('SELECT * FROM CaseTable', [], queryexcecute, errorCB);
   }
   function queryexcecute(tx, result) {
       var len = result.rows.length;

       for (var i = 0; i < len; i++) {
         if(result.rows.item(i).CaseName ==$('.caseName_h').val()){
           alert("Folder is already Exit.");
           isvalid=false;
           Break;
           return;;
         }
       }
      }



I am calling this like this.

$(document).on('click', '#AddButton', function() {
     isvalid = validationField();
    if (isvalid) {
            insertData();
            window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail);
    }
});

解决方案

('.caseName_h').val()){ alert("Folder is already Exit."); isvalid=false; Break; return;; } } }



I am calling this like this.


(document).on('click', '#AddButton', function() { isvalid = validationField(); if (isvalid) { insertData(); window.requestFileSystem(LocalFileSystem.PERSISTENT, 0, onFileSystemSuccess, onFileSystemFail); } });


这篇关于如何检查sqlite phonegap中列中的重复项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆