I am trying to use a SQLite plugin for PhoneGap for Windows Phone 8. I've found 2 or 3 different plugins (maybe all of them are based from the same base) and all give me an error when the applicattion is executed.
The plugin I'm using is from here: https://github.com/marcucio/Cordova-WP-SqlitePlugin
I am including also the dll. I'm using PhoneGap 3.3.
When I execute the application, the plugin is loaded (it seems is loades correctly) and some operations are done correctly (some CREATE and some INSERT are performed) but at a given moment the Visual Studio gives me this error infinite times:
An exception of type 'System.Security.SecurityException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
An exception of type 'System.Security.SecurityException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.IO.IsolatedStorage.IsolatedStorageException' occurred in mscorlib.ni.dll
I've tried other similar plugins and the error still appears.
The other threads in stackoverflow related to this problem didn't solve the problem. The application always crashes in an IsolatedStorage operation.
Anyone had the same problem and could solve it? If I don't perform any INSERT operation the plugin doesn't crash.
Thank you.
I had the same problem using Community.CsharpSqlite.WinPhone, it's possible that we have the same issue.
This happened when I did an INSERT OR REPLACE or INSERT OR IGNORE with a table which primary key was TEXT and had NOT NULL constraint. If the primary key is INTEGER and AUTOINCREMENT, it works fine.
For example:
CREATE TABLE table1 (
tableid TEXT NOT NULL,
value TEXT NOT NULL,
PRIMARY KEY(tableid)
);
INSERT or REPLACE INTO table1 (tableid, value) VALUES ("id1","test");
If your id column has NOT NULL constraint, SQLite will return a System.Security.SecurityException. Try to remove this constraint:
CREATE TABLE table1 (
tableid TEXT,
value TEXT NOT NULL,
PRIMARY KEY(tableid)
);
It's a bug, in other platforms (Android, iOS, etc) the table can have a NOT NULL constraint and it works fine.
Related
I'm trying to find out, which programming language is used in these functions - newVersion() and curVersion(). I've tried to search in Google, even on exact match like "newVersion()" OR "curVersion()", but it does not find.
As db is used sqlite db.
If short, it's proprietary app and I don't have access to source code of app, but I have to resolve the issue with pop-up error in Android app.
Have anyone some ideas about that?
CREATE TABLE "tblEvents" (
--some fields before
"version" int NOT NULL DEFAULT (newVersion()),
"isModified" int NOT NULL GENERATED ALWAYS AS ("version" > curVersion()) VIRTUAL,
);
The error occurs in one of these triggers:
CREATE TRIGGER [tr_i_tblEvents]
BEFORE INSERT ON [tblEvents]
WHEN isVersionEnabled() AND new.version<>newVersion()
BEGIN SELECT RAISE(FAIL, 'DON''T TOUCH ROW VERSION!!!'); ENDл
CREATE TRIGGER [tr_u_tblEvents]
BEFORE UPDATE OF version,SyncStatus,[EventId],[EventTypeId],[Name],[Description],[DateStart],[DateEnd],[CreationDate],[EventStatus],[OrgStructureID],[Color],[Location],[Mode],[StaffGroupID],[PlannedDay],[Recurrence_ID]
ON [tblEvents]
WHEN isVersionEnabled() AND new.version<>newVersion()
BEGIN SELECT CASE WHEN new.version<>old.version THEN RAISE(FAIL, 'DON''T TOUCH ROW VERSION!!!') END;
update [tblEvents] set version=newVersion() where rowId=old.rowId; ENDБ
I am currently working on a database structure in SQLite Studio (not sure whether that's in itself important, but might as well mention), and error messages are making me wonder whether I'm just going at it the wrong way or there's some subtlety I'm missing.
Assume two tables, people-basics (person-ID, person-NAME, person-GENDER) and people-stats (person-ID, person-NAME, person-SIZE). What I'm looking into achieving is "Every record in people-basics corresponds to a single record in people-stats.", ideally with the added property that person-ID and person-NAME in people-stats reflect the associated person-ID and person-NAME in people-basics.
I've been assuming up to now that one would achieve this with Foreign Keys, but I've also been unable to get this to work.
When I add a person in people-basics, it works fine, but then when I go over to people-stats no corresponding record exists and if I try to create one and fill the Foreign Key column with corresponding data, I get this message: "Cannot edit this cell. Details: Error while executing SQL query on database 'People': no such column: people-basics.person" (I think the message is truncated).
The DDL I currently have for my tables (auto-generated by SQLite Studio based on my GUI operations):
CREATE TABLE [people-basics] (
[person-ID] INTEGER PRIMARY KEY AUTOINCREMENT
UNIQUE
NOT NULL,
[person-NAME] TEXT UNIQUE
NOT NULL,
[person-GENDER] TEXT
);
CREATE TABLE [people-stats] (
[person-NAME] TEXT REFERENCES [people-basics] ([person-NAME]),
[person-SIZE] NUMERIC
);
(I've removed the person-ID column from people-stats for now as it seemed like I should only have one foreign key at a time, not sure whether that's true.)
Alright, that was a little silly.
The entire problem was solved by removing hyphens from table names and column names. (So: charBasics instead of char-basics, etc.)
Ah well.
It's been a while since I used SQL, and I am relearning a lot. However, I cannot figure out why my DEFAULT values are causing errors in my SQL with SQLite. I have created 4 tables, and most of them use DEFAULT values of some sort.
Before, I was able to create test data in my database (with these default values). Now, for some reason, these cause errors, and I cannot figure out why.
DDL
Here is one of my tables. Look at the last 4 columns in the SQL (i.e. is_usdr_created, is_continuous_play, is_random_play, repeat_all_play)
CREATE TABLE IF NOT EXISTS playlists (
playlist_id INT NOT NULL,
category_id INT NOT NULL,
name TEXT NOT NULL CHECK (trim(name) != ''),
video_count INT CHECK (video_count > 0),
is_user_created BOOLEAN DEFAULT (0),
is_continuous_play BOOLEAN DEFAULT (1),
is_random_play BOOLEAN DEFAULT (0),
repeat_all_play BOOLEAN DEFAULT (0),
PRIMARY KEY (playlist_id),
FOREIGN KEY (category_id) REFERENCES categories (category_id)
);
Error
[1] [SQLITE_ERROR] SQL error or missing database (near "DEFAULT": syntax error)
If I remove all the DEFAULT keywords and values, then everything works fine. Why is that?
NOTE: I just edited this once I realized this problem is now more widespread to all my tables with default values.
I also decided to create a new project, just in case this was an issue with the previous project; however, this issue is still occuring with the new project.
The following code causes a syntax error in SQLite.
I imagine this must be simple but I can't see it.
I have two tables, pages and items, linked through a text code. When this code in changed in pages table, I want it changed in items table too.
The SQLite version is quite old, 3.7.7.1, but I haven't seen such a problem in version history. This occurs on Windows, with PHP 5.3.1.
CREATE TABLE IF NOT EXISTS "efpage" ( "pageid" integer NOT NULL PRIMARY KEY, "psite" text NULL, "pgcode" text NULL );
CREATE TABLE IF NOT EXISTS "efitem" ( "itemid" integer NULL PRIMARY KEY , "isite" text NULL, "ititle" text NULL, "inpage" text NULL);
DROP TRIGGER IF EXISTS update_pagecode;
CREATE TRIGGER update_pagecode AFTER UPDATE OF pgcode ON efpage
BEGIN
UPDATE efitem SET inpage = new.pgcode WHERE inpage = old.pgcode;
END;
The resulting error is
ERROR near "pgcode": syntax error.
Trying different things, I saw that the syntax error is after "old.pgcode;"
As indicated by CL,
this is linked to the version of SQLite.
I use SQLite bundled with PHP on windows.
The next (answered) question for me is :
How to update the SQLite version bundled with PHP
I've run into a very puzzling problem regarding a table in a Sqlite database.
The table has this simple DDL definition:
CREATE TABLE [MATable2] ([ID] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
[AName] VARCHAR(20), [AMemo] MEMO)
Using XE6, DBExpress and v.3.8.5.0 of sqlite3.dll I've created a project
to investigate another SO q. The project (32-bit target) is deliberately as minimalist as I could make it, i.e. I've just pulled off the component palette a SqlConnection,
SqlQuery (which just does a 'SELECT * from [MATable2]'), DataSetProvider, CDS,
DataSource, DBGrid and DBNavigator wired up in left-to-right order as it were.
The code is equally minimalist, and I don't think I need show it because my
problem isn't with the code per se, which works fine.
The problem I've been getting is this: Every now and then, usually after I've made
some blunder that generates an exception (like calling CDS.Refresh in its ApplyUpdates event) the project (I would say "or its server" if the server in Sqlite's case weren't just
a dll) gets into an "error condition" which persists across restarting the XE6 IDE and
rebooting the machine. It manifests itself by the SqlQuery.Open generating an exception
complaining about a mismatch between the expected and actual field types, e.g. in the
case of the ID field, the exception will report that it was expecting a WideMemo field but received a LargeInt one instead - it's as if there is something off by one in the table's metadata as received by the SqlQuery.
Thinking this condition might be DBX-specfic, and something to do with Sqlite column
types really being thinly-disguised memo fields, I created a FireDac equivalent
project and that gets the error condition, too. Then, the condition clears,
as mysteriously as it appeared, usually after I delete the dataset components +
TFields and replace them.
So, my question is, does anyone know where can the error cause could be persisting, I mean
such that it survives IDE restarts and machine reboots? My first thought was in the DFM, because of what I've said about how it spontaneously clears. Next, I suspected the database itself, but it seems perfectly tickety-boo accessed, queried and recreated using two independent Sqlite utilities, Sqlite Expert and the Sqlite Manager add-in for Firefox. The OS reports the disk as w/out errors. I've looked for persisted info that might be the cause, in Ini files and the Registry, but found nothing obvious.