ssummeraw 2013-06-08 05:07 采纳率: 10%
浏览 3617

在 index 4 的 bind value 是 null

我使用的下面的代码,但是给出错误

String updateQuery ="INSERT INTO MAAccounts(userId, accountId, accountType, accountName, parentAccountId, currencyCode, isTransactionDefaultStatusOpen, currentBalance, monthlyBudget, createdOn, updatedOn) VALUES(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; 
        String[] valVars = { 
                stringToDB(account.userId),
                integerToDB(account.accountId).toString(),
                integerToDB(account.accountType.getValue()).toString(),
                stringToDB(account.accountName),
                (integerToDB(account.parentAccountId) != null ? integerToDB(account.parentAccountId).toString() : null),
                stringToDB(account.currencyCode),
                boolToDB(account.isTransactionDefaultStatusOpen).toString(),
                CurrencyToDB(account.currentBalance).toString(),
                CurrencyToDB(account.monthlyBudget).toString(),
                dateToDB(now),
                "false"};

        Cursor c = mDb.rawQuery(updateQuery, valVars);

错误:java.lang.IllegalArgumentException: the bind value at index 4 is null

请问如何解释这个错误?

  • 写回答

1条回答

  • 北边的世界 2013-06-08 10:51
    关注

    这个错误的意思是你sql语句中绑定的第四个值是空的。(integerToDB(account.parentAccountId) != null ? integerToDB(account.parentAccountId).toString() : null),
    这个判断语句中可能返回了一个null,因此报错。

    评论

报告相同问题?

悬赏问题

  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 latex怎么处理论文引理引用参考文献