I have an SQLite database, testing on my Andorid device, with a simple table, where I don’t seem to be able to get the SQLite delete command working.
I’ve removed the primary key etc to take that out of the equation.
My SQL looks like the following…
DELETE FROM MyTable WHERE GroupName = 'cars' AND Id IN ('CAR01','CAR02')
// Full code...
let db = await this.sqlite.create({name: 'mydb.sqlite', location: 'default'});
let delSql = `DELETE FROM ${this.TABLE_NAME} WHERE GroupName = '${groupName}' AND Id IN ('CAR01','CAR02');
await db.executeSql(delSql);
I just need to be able to delete before adding in new values. Inserts work fine, but whenever I try to delete, I get an exception with just the following…
No error strings, or no error in the console.
When I copy the database from the device, onto my desktop, and run the same SQL, it works no problems.
My Ionic info is
$ ionic info
cli packages: (C:\Users\peterc\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 7.0.1
local packages:
@ionic/app-scripts : 3.1.0
Cordova Platforms : android 6.2.3
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.0.2
Node : v8.11.3
npm : 5.6.0
OS : Windows 10
Environment Variables:
ANDROID_HOME : C:\Users\peterc\AppData\Local\Android\sdk
Misc:
backend : legacy
Does anyone have any ideas about this?
[UPDATE]
After the whole day on this, I realised, the delete was actually working (ie deleting), but it always throws the above exception even when it succeeds.
So I have had to add a local "exception gobbler "
try {
await db.executeSql(delSql);
} catch (error) {
}
So I suppose the question is now why I always get an exception (that seems to have no details)
Thanks in advance