I'm developing android Using SQLite , When inserting I'm having android.database.sqlite.SQLiteException: near "If" ... This is my code :
String query =
" If Exists(Select " + orderID + " From Print Where " + categoryNum + "= " + itemID + " and " + orderID + " = " + holdedOrderID + " )" +
" BEGIN " +
" UPDATE Print Set " + qty + " = " + qty + "+ " + QTY +
" Where " + categoryNum + "= " + itemID + " and " + orderID + " = " + holdedOrderID +
" END " +
" Else " +
" BEGIN " +
" Insert Into orderDetails ( " + PRODUCT_NAME +","+ categoryName +","+ categoryNum +","+ orderID +","+ price +","+ qty + " , " + tabelNumber +")"
+ " Values (" + "'" + itemName + "'" +","+ "'" +itemCategory + "'" +","+ itemID +","+ "'" + holdedOrderID + "'" + ","+ itemPrice +","+ QTY +","+ "'" +tableNumberz + "'" + ") " +
" END";
mDb.execSQL(query);
Aucun commentaire:
Enregistrer un commentaire