javascript - SQL 删除未按预期工作

标签 javascript sqlite titanium

如果我将每个(一次一个)放在相同的代码中,第二个会将标题更新为 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,看看它是否真的正确,或者看看 sql 是否返回任何错误。

关于javascript - SQL 删除未按预期工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24724554/

相关文章:

javascript - winjs应用程序中的导航问题

Javascript form.submit() 失败并停止执行其余的 javascript 代码

sqlite - SQLite 中的多个更新触发器

python - flask session : how to create the session table

android - 用于移动 Web 应用程序的 Titanium 还是 PhoneGap?

javascript - React babel loader - 你可能需要一个合适的加载器来处理这种文件类型

javascript - 以管理员身份发布 Facebook 页面(也有页面 access_token)

java - 最接近的匹配值 sqlite

javascript - 在 Titanium 中创建一个充满动态按钮网格的可 ScrollView

javascript - Titanium 选项卡式 iPhone 应用程序中的内存泄漏