Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: SQL Sqlite PhoneGap
I need to check duplicate item in sqlite before inserting the data in table .I need to check whether it already present or not .I have a create a table.
 
tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName TEXT NOT NULL UNIQUE,CaseDate INTEGER ,TextArea TEXT NOT NULL)');
 
$(document).on('click', '#AddButton', function() {
 

checkExitingFolderName();
insertData();
 
}
});
 
function checkExitingFolderName(){
db.transaction(getallTableCntend, errorCB);
}
 
function getallTableCntend(tx) {
var str=tx.executeSql('SELECT 1 FROM CaseTable WHERE CaseName ='+$('.caseName_h').val());
alert("str"+str);
}
Posted 13-Jul-13 5:32am
Comments
ThePhantomUpvoter at 13-Jul-13 11:08am
   
Okay.... and? Did you have a question or maybe a description of some sort of a problem?
ravi1989h at 13-Jul-13 11:51am
   
i have problem
CHill60 at 13-Jul-13 13:02pm
   
Do you want to describe that problem in a little more detail? We can't read your mind and we don't have enough information to even begin to try to help you. I think you may need to look at
'SELECT 1 FROM CaseTable WHERE CaseName ='+$('.caseName_h').val() - what does that actually equate to?
ravi1989h at 13-Jul-13 13:22pm
   
ok i will explain my problem ..Actually i have one table "CaseTable" i need to check there is no duplicate item in my first column "CaseName".So i need to validate that thing
ravi1989h at 13-Jul-13 13:22pm
   
i try Unique But not working..
ryanb31 at 13-Jul-13 22:15pm
   
You have to reply tot he comment or else the user is not notified. Please do not post a new comment to your own question.
ravi1989h at 13-Jul-13 13:24pm
   
i just check by using query that is there same entity present in column
ryanb31 at 13-Jul-13 22:15pm
   
What's your question? You have only posted bits of code. If this is all your code then the problem is you haven't finished the code.

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

i done it..using unique and insert or ignore keyword
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web02 | 2.8.1411023.1 | Last Updated 14 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100