开发者

Performing a query results in a "no such column" exception

开发者 https://www.devze.com 2023-04-05 16:01 出处:网络
My query is dbAdapter.selectRecordsFromDB(\"OmniaDB\",new 开发者_如何学CString[]{\"imsi\",\"type\",\"msg\",\"length\",\"dt_gen\",\"dt_send\"},\"type\"+\"=\"+\"call\"+\"AND\"+\"dt_send\"+\"=\"+\"null

My query is

 dbAdapter.selectRecordsFromDB("OmniaDB",new 开发者_如何学CString[]{"imsi","type","msg","length","dt_gen","dt_send"},"type"+"="+"call"+"AND"+"dt_send"+"="+"null",null,null,null,"dt_gen"); 

Thrown exception is

android.database.sqlite.SQLiteException: no such column: callANDdt_send: , while compiling: SELECT imsi, type, msg, length, dt_gen, dt_send FROM OmniaDB WHERE type=callANDdt_send=null ORDER BY dt_gen


You're missing a ton of spaces in "type"+"="+"call"+"AND"+"dt_send"+"="+"null", should be "type='call' AND dt_send=null". Why are you even using concatenation when it should be a giant string? Anyway, there might be something else wrong after you fix that, though, since I have no clue what your data looks like.


"type"+"="+"call"+"AND"+"dt_send"+"="+"null"

None of this makes sense. Getting rid of the unnecessary concatenations leaves

"type = call AND dt_send = null"

which is invalid SQL. You're not quoting properly for the string call, and you can't compare NULL for equality with anything (including NULL).

This is more likely what you should be using:

"type = 'call' AND dt_send IS NULL"

There are probably other problems with the mess you posted, but this should solve at least one of them. (For instance, type may be a reserved word in SQLite; I'm not sure.)

0

精彩评论

暂无评论...
验证码 换一张
取 消