Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to call synchronise call in sqlite phonegap (check duplicate item before insert )
    primarykey
    data
    text
    <p>I need to check duplicate columns(item) before inserting the data in table .But it is asynchronise call .so it is not working .I need to call synchronise call so that i can get value <strong>true and false</strong> </p> <p>Then check for insert value or not.</p> <pre><code>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 &lt; 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); } }); </code></pre> <hr> <p>May i create table Like that.. tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName TEXT NOT NULL UNIQUE,CaseDate INTEGER ,TextArea TEXT NOT NULL)'); and Use Like That...</p> <pre><code>tx.executeSql('INSERT OR IGNORE INTO CaseTable(CaseName,CaseDate,TextArea) VALUES ("' + $('.caseName_h').val() + '", "' + $('.caseDate_h').val() + '","' + $('.caseTextArea_h').val() + '")'); </code></pre> <p>----------------------------------------------Do like that--------------</p> <pre><code>function checkExitingFolderName(){ db.transaction(getallTableCntend, errorCB); } function getallTableCntend(tx) { tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+$('.caseName_h').val(), [], queryexcecute, errorCB); } function queryexcecute(tx, result) { var len = result.rows.length; alert("hi"+length); if(len&gt;0){ alert("Folder") } else{ insertData(); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload