window.serDB = window.openDatabase("mytable", "1.0", "medical alerts", 1 * 1024 * 1024); tx.executeSql("CREATE TABLE IF NOT EXISTS mytable (msg_id UNSIGNED INT PRIMARY KEY ASC, msg_when DATETIME, msg_read INTEGER, title TEXT, msg_text TEXT)",
tx.executeSql("INSERT OR REPLACE INTO mytable(msg_id, msg_when, msg_read, title, msg_text) VALUES (?,?,0,?,?)",[...] json: {"status":"OK","count":1,"last_id":"44","when":"2016-08-23 11:21:01","alerts":[{"msg_id":"44","title":"Medical Emergency","text":"Heart Attack","msg_when":"2016-08-05 14:52:03"}]}
tx.executeSql("DELETE FROM mytable WHERE msg_when <= datetime('now', '-" +days +" days')", [], tx.executeSql("DELETE FROM mytable WHERE msg_when <= datetime('now', '-4 days')"; [], tx.executeSql("DELETE FROM mytable;", [], tx.executeSql("DROP mytable;", [],A couple quick thoughts:
- You've got semicolons at the end of your DELETE and DROP statements; remove them and they should work.
- As to why your datetime statement is failing, try wrapping your when column with a datetime function as well so that you're comparing dates to dates.
- I do suggest a plugin for SQLite just because it gets around the quota limitation that the native implementation has (5-10mb). I use https://www.npmjs.com/package/cordova-sqlite-ext
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/za7z51_fKRw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
...
...
tx.executeSql("CREATE TABLE IF NOT EXISTS mytable (msg_id UNSIGNED INT PRIMARY KEY ASC, msg_when TEXT, msg_read INTEGER, title TEXT, msg_text TEXT)",
tx.executeSql(DELETE FROM mytable WHERE (msg_when <= datetime('now', '-4 days'))", --
$ sqlite3
SQLite version 3.8.10.2 2015-05-20 18:17:19
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> CREATE TABLE tt(name TEXT, created DATETIME);
sqlite> INSERT INTO tt VALUES ('Chris', DATETIME('NOW'));
sqlite> SELECT * FROM tt;
Chris|2016-09-01 19:15:24
sqlite> .dump
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
CREATE TABLE tt(name TEXT, created DATETIME);
INSERT INTO "tt" VALUES('Chris','2016-09-01 19:15:24');
COMMIT;
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/za7z51_fKRw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+u...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
For more info on PhoneGap or to download the code go to www.phonegap.com
---
You received this message because you are subscribed to a topic in the Google Groups "phonegap" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phonegap/za7z51_fKRw/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phonegap+unsubscribe@googlegroups.com.