If already exist just update or do something else. Its just easy way to do.
I have followed this code and written some phonegap application. easy to bind from the sqlite table further use to display the page.
function insertIndustry(industryID,industry) { db = window.openDatabase("mydb","0.1","InsuranceDb", 500000); var selectQuery ="SELECT COUNT(*) AS MyCount FROM industrymaster WHERE industryId="+industryID; db.transaction(function selectQueryDB(tx){tx.executeSql(selectQuery,[],function txSuccessResult(tx,results) { var messageid = results.rows.item(0)['MyCount']; if(messageid == 1) { console.log("exist"); } else { tx.executeSql("INSERT INTO industrymaster(industryId, industry) VALUES ("+industryID+",'"+industry+"')"); } },errorCB); }, errorDB); }
function errorCB(err) { console.log("Error processing SQL 1: "+err.code); } function errorDB(error) { console.log(error +"Error processing SQL 1: "); }
No comments:
Post a Comment