sqlite3 - SQLite query in Android does not return correct values -


the following query not return value sellingprice though in database. returns value other fields, except sellingprice.

select itemid, unitid, itemdesc, unitdescription, case ? when 1 sellingprice1 when 2 sellingprice2 when 3 sellingprice3 when 4 sellingprice4 when 5 sellingprice5 end sellingprice items companyid = ? order itemdesc, unitdescription 

if substitute ? 2 , 7, returns value sellingrice

select itemid, unitid, itemdesc, unitdescription, case 2 when 1 sellingprice1 when 2 sellingprice2 when 3 sellingprice3 when 4 sellingprice4 when 5 sellingprice5 end sellingprice items companyid = 7 order itemdesc, unitdescription 

here how execute query

cursor = dbcontext.rawquery(query, new string[] {integer.tostring(pricelevel), integer.tostring(companyid)}); 

and here how traverse returned cursor

if (cursor.movetofirst()) {         {             log.i("item desc", cursor.getstring(2));             log.i("sellingprice", double.tostring(cursor.getdouble(4)));              items.add(new itemdisplay(cursor.getint(0),                                          cursor.getint(1),                                         cursor.getstring(2),                                         cursor.getstring(3),                                         cursor.getdouble(4)));          } while (cursor.movetonext());     } 

please help.

thanks in advance.

solved it. turns out, rawquery uses parameters clause.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -