如果我将每个(一次一个)放在同一代码中,则第二个将标题更新为var testTitle,第一个不会删除与WHERE匹配的行/项目。

function deleteTableAItem(e) {
    var db3 = Ti.Database.open('thedatabase');

    var getTheID = db3.execute('SELECT ID FROM tableA WHERE myIndexColumn=?', e.itemIndex);
    var theID = getTheID.fieldByName('ID');

    Ti.API.info(tableLinkRef + " " + theID); //they match as intended

    var testTitle = "DID I CHANGE?";

    db3.execute('DELETE FROM tableB WHERE tableLinkRef=? AND tableARef=?',theID,theTableAItemClicked); // fixed by adding another comparison.

    //db3.execute('UPDATE tableB SET titleColumn=? WHERE tableLinkRef=?',testTitle,theID); // this DOES update the titleColumn in matching rows/items when the code is active and the previous is commented out

    db3.execute('DELETE FROM tableA WHERE myIndexColumn=?', e.itemIndex); //this deletes the row from the first table. I want to delete the rows I have associated in tableB as well

    db3.close();
}

最佳答案

您在代码中的DELETE sql看起来不错。您可以打印出生成的整个SQL,以查看它是否确实正确,或者查看sqlite返回任何错误的信息。

07-28 03:51