How to solve this query in database using sqlite phone gap

am facing a problem in recent days. The problem is database. In fact, I create the mane database 'casepad '. Then I created a table because the database 'table of cases' have (ID, name, date). Now I insert the value on this table. When inserting I also create a name ("casename") .mean table if I insert the value of the case table (1, 'AB', 2/13). Then I create table AB. Now I need to get the value of the case table (I am) but I need to count the number of items in another table (AB). Here, I had to try it.

function onDeviceReady() {

    db = window.openDatabase("Casepad", "1.0", "Casepad", 200000);

db.transaction(getallTableData, errorCB);

}

function insertData() {
    db.transaction(createTable, errorCB, afterSuccessTableCreation);
}

//createtableandinsertsome record
function createTable(tx) {
    tx.executeSql('CREATE TABLE IF NOT EXISTS CaseTable (id INTEGER PRIMARY KEY AUTOINCREMENT, CaseName  TEXT unique NOT NULL ,CaseDate INTEGER ,TextArea TEXT NOT NULL)');

    tx.executeSql('INSERT OR IGNORE INTO CaseTable(CaseName,CaseDate,TextArea) VALUES ("' + $('.caseName_h').val() + '", "' + $('.caseDate_h').val() + '","' + $('.caseTextArea_h').val() + '")');

}
//function will be called when an error occurred
function errorCB(err) {
    navigator.notification.alert("Error processing SQL: " + err.code);
}

//function will be called when process succeed
function afterSuccessTableCreation() {
    console.log("success!");
    db.transaction(getallTableData, errorCB);
}

//select all from SoccerPlayer
function getallTableData(tx) {
    tx.executeSql('SELECT * FROM CaseTable', [], querySuccess, errorCB);
}

function querySuccess(tx, result) {
    var len = result.rows.length;
    var t;
    $('#folderData').empty();
    for (var i = 0; i < len; i++) {

        $('#folderData').append(
                '
  • ' + '' + '' + '

    ' + result.rows.item(i).CaseName + t+'

    ' + '

    ' + result.rows.item(i).TextArea + '

    ' + '

    ' + result.rows.item(i).CaseDate + '

    ' + '' + i + '
    ' + '
    '+'
  • ' ); } $('#folderData').listview('refresh'); }

    Instend of show the value of 'i' in the view list, I need to show how many element in the table. I have to call synchronize because I call a query that counts the number of elements to 'result.rows.item (i). CaseName"this item... ?

    Hello

    If I understand correctly, you are looking for a SQL statement that you will get the count for the number of items in the table AB? If so, this can be useful:

    http://www.w3schools.com/SQL/sql_func_count.asp

    Please let me know if you have any other questions.

    Tags: BlackBerry Developers

    Similar Questions

    Maybe you are looking for