SQLMap.delete() Causing SQL Syntax Error

57 views
Skip to first unread message

Paul Wade

unread,
Apr 24, 2018, 8:32:36 PM4/24/18
to CodenameOne Discussions
I'm using Intellij IDEA.  Running the following code results in an SQL syntax error.

The code:

   private void clearAllEntries(Database db, SQLMap sqlMap) throws IOException, InstantiationException {
   
SignInListEntry signInListEntry = new SignInListEntry();
   
List<PropertyBusinessObject> objs = sqlMap.select(signInListEntry, signInListEntry.signInListId, true, 1000, 0);
   
Logger.log("Deleting " + objs.size() + " entries");
   
for (PropertyBusinessObject o : objs) {
      sqlMap
.delete(o);
   
}



The log message showing the DELETE statement:

   DELETE FROM SignInListDetail WHERE ,entryId = ?signInListId = ?firstName = ?lastName = ?email = ?officePhone = ?mobilePhone = ?organization = ?address1 = ?address2 = ?address3 = ?city = ?state = ?country = ?zip = ?  

And the error:

   java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (near ",": syntax error)

It's not a missing database because I can add records to the same database using the same Database object and SQLMap.  Am I doing something wrong or is this a CN1 bug?

Thomas

unread,
Apr 24, 2018, 9:40:18 PM4/24/18
to CodenameOne Discussions
yes looks like a typo in cn1. I think that inside the delete function of the SQLMap class `if(count == 0)` (line 501) should be `if(count != 0)` which is the reason why the DELETE statement is malformed.
Until it is fixed by the CN1 team, you should try to create a simple SQL statement yourself to clean your table (TRUNCATE TABLE SignInListDetail should probably work and you could try TRUNCATE TABLE ?  or DELETE FROM ? if you want to clean every table in you database) which should be more efficient anyway

Shai Almog

unread,
Apr 25, 2018, 1:35:50 AM4/25/18
to CodenameOne Discussions
Thanks!
Should be fixed for this Friday update.
Reply all
Reply to author
Forward
0 new messages