Click here to Skip to main content
15,892,537 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Comments
[no name] 13-Jul-13 11:08am    
Okay.... and? Did you have a question or maybe a description of some sort of a problem?
ravi1989h 13-Jul-13 11:51am    
i have problem
CHill60 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 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 13-Jul-13 13:22pm    
i try Unique But not working..

1 solution

i done it..using unique and insert or ignore keyword
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900