I'm trying to get our current database to use FTS. I recompiled the project with FTS3 and FTS4 support on. I know this part works since I've tried some of the examples off of the sqlite pages and they work.
e.g.
CREATE TABLE t2(id INTEGER PRIMARY KEY, a, b, c);
CREATE VIRTUAL TABLE t3 USING fts4(content="t2", a, c);
What I want to do is add a Virtual table to a .db that is already saved to the documents directory of our app. It is writeable.
My question is multi part. First, I tried my query in Firefox's add-on SQLite manager. My query is this:
CREATE VIRTUAL TABLE VirtualTestTable USING fts4(content=Chromosomes, ID Integer Primary Key Autoincrement, rsID, ChrID, Position, Strand, GeneSymbol)
Once I run this in sqlite manager, it creates a few different tables (VirtualTestTable, VirtualTestTable_docsize, VirtualTestTable_segdir, VirtualTestTable_segments, VirtualTestTable_stat).
So I assume sqlite manager supports FTS4. My table is also populated with the data that was original in my Chromosomes Table. But when I try to match anything in the table, I always get zero results. So my first question is, does sqlite manager support FTS queries?
My other question, which is more important to me, is if my query works in sqlite manager, I try this query in my Xcode project with different variations of
content='Chromosomes'
content=\"Chromosomes\"
content=Chromosomes
I always get an error with my query. I'm using FMDB and using the executeUpdate: message. My error is:
Error calling sqlite3_step (1: SQL logic error or missing database) SQLITE_ERROR
Unknown error finalizing or resetting statement (1: unrecognized parameter: content=Chromosomes)
Does anyone know why I'm getting this error? I don't think it's a missing database as when I try to just create an empty Virtual table on my fmdatabase, it runs fine. Thanks.
FTS queries work just fine in SQL Manager:
CREATE VIRTUAL TABLE t USING FTS4(x);
INSERT INTO t VALUES('blah');
INSERT INTO t VALUES('blubb');
SELECT * FROM t WHERE x MATCH 'bl*';
The error message "unrecognized parameter: content=" is typical for SQLite versions that do not support contentless/external content tables, i.e., ones older than 3.7.11.
Related
We have some very simple (id INTEGER PRIMARY KEY, data BYTE)-tables that I'm trying to retrieve the data from, but seem to run into some kind of data corruption. When accessing or retrieving the data-column e.g. via SELECT data FROM foobar WHERE id = 42 or SELECT LENGTH(data) FROM foo WHERE id = 42 I get
[HY000] [Informix][Informix ODBC Driver][Informix]Text/Byte subscript error. (-607) (SQLFetch)
which is obviously weird, as no byte subscript operator is used. It rather seems to me Informix is running into some kind of data corruption issue and is unable to retrieve the underlying BLOB. The query works if I explicitly exclude the offending row, so SELECT SUM(LENGTH(data)) FROM foo fails with the above error, while SELECT SUM(LENGTH(data)) FROM foo WHERE id NOT IN (42,...) succeeds.
For other rows, I retrieve an error
[01004] [Informix][Informix ODBC Driver]Data truncated. (-11003) (SQLGetData)
which also can only be mitigated by (finding and) excluding the offending row via their primary key.
First of all, is there a way to tell if this is a driver/odbc error or if the underlying data is actually corrupted? Is there a way to check the tables for data corruption, instead of running into this kind of problem one by one?
This is IBM Informix Dynamic Server Version 14.10.FC5WE
It sounds to me like running the same query, but using different tool or method, would give you an idea if it's the driver or the data itself.
If the data is corrupted, you can use the following to confirm the checksum value and identify:
CHECKSUM TABLE foobar;
Also, obviously updating the driver version is given, have you tried that?
I'm trying to integrate my Oracle Database into my ASP.NET app, but I keep getting this error :
Error 2002: The EntityContainer 'OracleDBTargetContainer' for the
storage model specified as part of this MSL does not exist in
MetadataWorkspace.
I've tried everything I could think of but still can't figure out what's wrong.
What can I do to diagnose the root cause of this?
This is still new to me so I might miss something very obvious.
I'm assuming it my not like my database as the Diagram displayed when I integrated another DB. I've checked the foreign keys, primary keys, ... but to no good.
Using VS2013 with ODP.NET 12c Release 3.
EDIT : My EntityContainerMapping is empty, is that normal?
<EntityContainerMapping CdmEntityContainer="PMModelContainer" StorageEntityContainer="PMModelTargetContainer"></EntityContainerMapping>
I found what was wrong.
One of my foreign key didn't match the primary key (Number 20 instead of Number 10)
I saw on stack overflow that it could be a problem and checked my tables but I missed that one obviously.
How did I realize it ? Well because rather than creating the EF Designer, I chose the Code First from database option, and, oh, what do you know, the error message now tells you EXACTLY what the problem is ! (Table names and columns).
I want to save the results of the MVC MiniProfiler to a sql server database. I profile a high load mvc4 page to spot a tricky performance problem which is non-reproducible on our test or development system and only happens sporadically on the production server.
What is the best way to hook into the mini profiler? Is there an existing extension to do that?
I've just been setting up MiniProfiler to save the results to SQL Azure, it's fairly easy. We're using MiniProfiler.MVC3 to take care of all the wiring up as described here.
The table create script is embedded into the assembly with the SqlServerStorage.TableCreationScript static field, so you can use that, but while digging into the code I found the latest development branch has enhanced the script slightly by adding some indexes. The table structure is otherwise unchanged, so it still works with the latest package available on nuget.
At the time of writing here is direct link to the latest table create script.
After that the only thing you need to do is set-up MiniProfiler to use SQL with single line of code:
MiniProfiler.Settings.Storage = new SqlServerStorage("<your connection string>");
If you're not using SQL Azure, that's it, but I found one issue when we tried to use it in Azure. I received the following exception (thank you ELMAH) when profiling tried to save:
System.Data.SqlClient.SqlException
Tables without a clustered index are not supported in this version of SQL Server. Please create a clustered index and try again.
To solve this I had to add an additional (unused) column to the MiniProfilers table. Here is the beginning of the create table script in question:
create table MiniProfilers
(
RowId integer not null identity constraint PK_MiniProfilers primary key clustered, -- Need a clustered primary key for SQL azure
Id uniqueidentifier not null,
Name nvarchar(200) not null,
And since the Guid Id column was no longer the primary key, I added an additional index to ensure lookups are still fast:
create unique nonclustered index IX_MiniProfilers_Id on MiniProfilers (Id)
Hope that helps.
Update
The change to support SQL Azure has been provided as a Pull Request and accepted. Thanks Jarrod.
I have a table and am using ASP.NET MVC to create an object and save it. It's been working fine for a while. Somehow, recently, I started getting this error message on the production machine:
System.Data.SqlClient.SqlException: String or binary data would be truncated.
I can't seem to replicate the same error on my development machine. Is there anyway to find out what column is causing this? I'm running MSSQL 2008 R2 Express.
This usually occurs when you're trying to insert data that is longer than the field size defined on SQL Server. You can increase the size of the field in the database to solve the problem. If you're accepting user input and saving it to the database then you should be validating it against the defined maximum size of the database field.
Caused by data-length mismatch between your insert data and the defined column in your database. It indicates that the database would have to cut of data from your insert to be able to store it.
You may take closer look to the inner exception, I don't know it for sure, but I think you find more information there about the column that throws that error. And yes, you should prevent the users from inserting too long values and catch this in your model.
If you, for what ever don't want to implement a additional validation you should log the exception with the content that you tried to insert/update and then compare the values with the db.
I'm using Firebird 2.5.0 with the Entity Framework, which has been working well. However, recently I have changed something (I presume) and now the SQL that is being generated when I try to save my changes is not valid for Firebird:
update ( select [fields] from [table]) set [field] = #p0 where ([keyfieldn = #pn])
As far as I know, Firebird 2.5.0 does not support this syntax, and when I try to save changes I get back a SQL error that says as much ( "Token unknown, column 8: (" )
I'm not sure what to do now. What would cause the UpdateTranslator instance to generate this SQL instead of whatever it must have been generating before I broke it?
I went back through the edmx file and found that I had gotten some 'DefiningQuery' elements when I had it pull in some new fields from the database. I couldn't find any way to access those settings in the interface, so I just deleted them from the file and it is working correctly again.