0

this is my error:

09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.native_compile(Native Method)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.compile(SQLiteCompiledSql.java:92)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteCompiledSql.<init>(SQLiteCompiledSql.java:65)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteProgram.<init>(SQLiteProgram.java:83)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteStatement.<init>(SQLiteStatement.java:41)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteDatabase.compileStatement(SQLiteDatabase.java:1149)
09-27 08:16:34.547: WARN/System.err(8366):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1802)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1168)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:179)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 08:16:34.557: WARN/System.err(8366):     at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 08:16:34.557: WARN/System.err(8366):     at java.lang.Thread.run(Thread.java:1019)

and this is my code of updateItem method where the database should be updated:

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET ( " +
                    CMSConstants.ID + ", " +
                    CMSConstants.TITLE + ", " +
                    CMSConstants.IS_PAGE + ", " +
                    CMSConstants.IS_HIDDEN + ", " +
                    CMSConstants.ITEM_TYPE + ", " +
                    CMSConstants.ORDER_INDEX + ", " +
                    CMSConstants.SECTION_ID + ", " +
                    CMSConstants.TABLE_SECTION_NAME + ", " +
                    CMSConstants.TABLE_SECTION_ID + ", " +
                    CMSConstants.IMAGE1_FILE + ", " +
                    CMSConstants.IMAGE1_CAPTION + ", " +
                    CMSConstants.IMAGE1_DISPLAY_IN_GALLERY + ", " +
                    CMSConstants.CATEGORY1 + ", " +
                    CMSConstants.CATEGORY2 + ", " +
                    CMSConstants.GEO_LONGITUDE + ", " +
                    CMSConstants.GEO_LATITUDE + ", " +
                    CMSConstants.DESCRIPTION + ", " +
                    CMSConstants.KEYWORDS + ", " +
                    CMSConstants.BLOCKWORDS + ", " +
                    CMSConstants.CLEAN_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD1_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD1_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD2_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD2_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD3_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD3_VALUE + ", " +
                    CMSConstants.ADDITIONAL_FIELD4_NAME + ", " +
                    CMSConstants.ADDITIONAL_FIELD4_VALUE + ", " +
                    CMSConstants.ADDRESS_LINE1 + ", " +
                    CMSConstants.ADDRESS_LINE2 + ", " +
                    CMSConstants.ADDRESS_LINE3 + ", " +
                    CMSConstants.ADDRESS_LINE4 + ", " +
                    CMSConstants.ADDRESS_LINE5 + ", " +
                    CMSConstants.ADDRESS_POSTCODE + ", " +
                    CMSConstants.CONTACT_EMAIL + ", " +
                    CMSConstants.CONTACT_EMAIL_DISPLAY + ", " +
                    CMSConstants.CONTACT_EMAIL_SUBJECT + ", " +
                    CMSConstants.CONTACT_TEL + ", " +
                    CMSConstants.CONTACT_TEL_DISPLAY + ", " +
                    CMSConstants.CONTACT_WEB + ", " +
                    CMSConstants.CONTACT_WEB_DISPLAY + ", " +
                    CMSConstants.MODIFICATION_DATE + ", " +
                    CMSConstants.PAGE_HEADER +
                    " ) VALUES ( " +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,?,?,?,?,?,?,?,?," +
                    "?,?,? );", bindArgs);

I don't understand where the problem is. I looked on the code and there is no problem near "(".

Hope someone can help me.

thanx newone

EDIT: This is my new query

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET " +
                CMSConstants.ID + "= ?, " +
                CMSConstants.TITLE + " = ?, " +
                CMSConstants.IS_PAGE + " = ?, " +
                CMSConstants.IS_HIDDEN + " = ?, " +
                CMSConstants.ITEM_TYPE + " = ?, " +
                CMSConstants.ORDER_INDEX + " = ?, " +
                CMSConstants.SECTION_ID + " = ?, " +
                CMSConstants.TABLE_SECTION_NAME + " = ?, " +
                CMSConstants.TABLE_SECTION_ID + " = ?, " +
                CMSConstants.IMAGE1_FILE + " = ?, " +
                CMSConstants.IMAGE1_CAPTION + " = ?, " +
                CMSConstants.IMAGE1_DISPLAY_IN_GALLERY + " = ?, " +
                CMSConstants.CATEGORY1 + " = ?, " +
                CMSConstants.CATEGORY2 + " = ?, " +
                CMSConstants.GEO_LONGITUDE + " = ?, " +
                CMSConstants.GEO_LATITUDE + " = ?, " +
                CMSConstants.DESCRIPTION + " = ?, " +
                CMSConstants.KEYWORDS + " = ?, " +
                CMSConstants.BLOCKWORDS + " = ?, " +
                CMSConstants.CLEAN_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD1_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD1_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD2_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD2_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD3_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD3_VALUE + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD4_NAME + " = ?, " +
                CMSConstants.ADDITIONAL_FIELD4_VALUE + " = ?, " +
                CMSConstants.ADDRESS_LINE1 + " = ?, " +
                CMSConstants.ADDRESS_LINE2 + " = ?, " +
                CMSConstants.ADDRESS_LINE3 + " = ?, " +
                CMSConstants.ADDRESS_LINE4 + " = ?, " +
                CMSConstants.ADDRESS_LINE5 + " = ?, " +
                CMSConstants.ADDRESS_POSTCODE + " = ?, " +
                CMSConstants.CONTACT_EMAIL + " = ?, " +
                CMSConstants.CONTACT_EMAIL_DISPLAY + " = ?, " +
                CMSConstants.CONTACT_EMAIL_SUBJECT + " = ?, " +
                CMSConstants.CONTACT_TEL + " = ?, " +
                CMSConstants.CONTACT_TEL_DISPLAY + " = ?, " +
                CMSConstants.CONTACT_WEB + " = ?, " +
                CMSConstants.CONTACT_WEB_DISPLAY + " = ?, " +
                CMSConstants.MODIFICATION_DATE + " = ?, " +
                CMSConstants.PAGE_HEADER + " = ?"
                , bindArgs);

and this is the new error:

09-27 09:39:03.105: WARN/System.err(8903): android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed
09-27 09:39:03.105: WARN/System.err(8903):     at android.database.sqlite.SQLiteStatement.native_execute(Native Method)
09-27 09:39:03.115: WARN/System.err(8903):     at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:61)
09-27 09:39:03.115: WARN/System.err(8903):     at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1809)
09-27 09:39:03.115: WARN/System.err(8903):     at  de.enough.appmate.dbase.CMSResource.updateItem(CMSResource.java:1221)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdater.updateItems(CMSResourceUpdater.java:178)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdater.loadUpdates(CMSResourceUpdater.java:102)
09-27 09:39:03.115: WARN/System.err(8903):     at de.enough.appmate.dbase.CMSResourceUpdaterRunnable.run(CMSResourceUpdaterRunnable.java:32)
09-27 09:39:03.115: WARN/System.err(8903):     at java.lang.Thread.run(Thread.java:1019)
2
  • 1
    Can you print your query to log and show it here? Commented Sep 27, 2011 at 6:53
  • I agree with @NikitaBeloglazov, you should prepare your query into a string and Log.d it before executing it. Easier to debug this way. Also, if you look at the error it seems that it's a constraint fail (invalid values), no more a SQL syntax error. You should also check your values. Commented Sep 27, 2011 at 8:21

1 Answer 1

2

try this

this.db.execSQL("UPDATE " + CMSConstants.ITEMS + " SET "+CMSConstants.ID+"="+value)

i think your query is wrong..

simple update query

"UPDATE TABLE_NAME SET COLUMN_NAME=COLUMN_VALUE"
Sign up to request clarification or add additional context in comments.

10 Comments

But I have more values. So how I would do that?
"UPDATE TABLE_NAME SET COLUMN_NAME1=COLUMN_VALUE1,COLUMN_NAME2=COLUMN_VALUE2,COLUMN_NAME3=COLUMN_VALUE3"
I think you have the right idea but newone should still be using placeholders instead of string concatenation and single quotes are standard for SQL string literals (even though SQLite allows double quotes).
@newone: You can still use placeholders with the proper update t set c1 = ?, c2 = ?, ... update SQL.
Sorry, but I have seen that when I make it like this than I get an error. It is: android.database.sqlite.SQLiteConstraintException: error code 19: constraint failed. Any ideas why it comes?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.