Weird errors -607/-11003 when retrieving BYTE-values - informix

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?

Related

Create Procedure from code or in Access?

Windows 10, Access 2016
I am moving a very small database (14 tables and 40-50 stored procedures) from SQL Server to Access. I have tried to recreate the stored procedures from code using an OLEDB command object. This is a sample of a CommandText…
CREATE PROCEDURE DeleteOrderDetailByOrderID
([#ID] int)
AS
DELETE FROM OrderDetails
WHERE (OrderID = #ID);
I get an error message that the Data Type of #ID is incorrect. It is not. When I remove the brackets from #ID all is forgiven and the code runs. However, Access strips the # from #ID in the parameter section (not in the Where clause). I have had to go into Access and manually correct this. I do not like the idea of going through almost 5000 lines of code to correct parameter names in my program. I thought I could use the direct approach by pasting the SQL directly into Access but I get an error with this route saying syntax error in CREATE TABLE and it highlights the word PROCEDURE. This leads me to believe that you cannot use CREATE PROCEDURE directly in Access. Is this true? Is there another approach that I am missing?
You are missing, that T-SQL of SQL Server is not Access SQL.
Access has UDFs - user defined functions - that can be used in queries also, but that is VBA code.
If you just need a single-user file based database to hold your data, you may get away with the SQL Server Compact Edition which supports a subset of T-SQL.

Complex T-SQL script executed via TADOQuery is firing "Multiple-step OLE DB operation generated errors."

I have a very large block of SQL that I am trying to execute inside of Delphi, against a Microsoft SQL Database. I am getting this:
Multiple-step OLE DB operation generated errors.
Check each OLE DB status value, if available. No work was done.
The script has multiple sql IF statements followed by BEGIN and END blocks with invocations of stored procedures, declaration of variables, and EXEC inside that. Finally it returns some of the variable values by SELECT #Variable1 AsName1,#Variable2 AsName2....
The above multi-step error is coming in as an OLEException from ADO, not from the Delphi code, and happens after all the SQL exec-stored-procedure have occurred, and therefore I suspect it's firing this OLE exception when it reaches the final stage which SELECT #Variable1 AsName1,... to get back a few variable values for my program to see them.
I know about this retired/deprecated MS KB article, and this is unfortunately not my actual issue:
http://support.microsoft.com/kb/269495
In short that KB article says to fix a registry key and remove "Persist Security Info" from the connection string. That's not my problem. I'm asking this question because I found the answer already and I think that someone else who gets stuck here might not want to waste several hours finding potential issues when there are several that I have found after searching for solutions for several hours. Anyone who wants to add another answer with different options, is fine, and I'll select yours if it's reproducible, and if necessary I'll turn this one into a Community Wiki because there could be a dozen obscure causes for this "ADO recordset is in a bad mood and is unhappy with your T-SQL" exception.
I have found several potential causes that are listed in various sources of documentation. The original KB article in the question suggests removing the 'Persist Security Info' from my ADO connection string, however in a standalone test in an application with just a TADOConnection and a single TADOQuery, the presence or absence of Persist Security Info had no effect, nor did explicitly setting it True or False.
What DID fix it was removing this CursorType declaration:
CursorType=ctKeyset
What I have learned is that bidirectional ADO datasets are fine for SELECT * FROM TABLE in ADO but are not so fine for complex SQL scripts.
Potential source of this error is updating char field with large value.
Example: Form has edit box with max length property set to 20 characters and Oracle database table has field defined as char(10).
Updating with 10 characters (or less) will work fine while updating with more then 10 characters will cause 'Multiple step...' error on ADOQuerry.UpdateBatch().
You also have to know that CHAR will allways have 20 characters. Consider Trimming value in edit box. CHAR behaves different than VARCHAR2 type.
If you have a query with parameter ,check the number of parameters in the query is matched with script...!

Uknown error finalizing or resetting statement in sqlite

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.

Parsing a CSV for Database Insertion when Formatted Incorrectly

I recently wrote a mailing platform for one of our employees to use. The system runs great, scales great, and is fun to use. However, it is currently inoperable due to a bug that I can't figure out how to fix (fairly inexperienced developer).
The process goes something like this...
Upload a CSV file to a specific FTP directory.
Go to the import_mailing_list page.
Choose a CSV file within the FTP directory.
Name and describe what the list contains.
Associate file headings with database columns.
Then, the back-end loops over each line of the file, associating the values with a heading, and importing these values into a database.
This all works wonderfully, except in a specific case, when a raw CSV is not correctly formatted. For example...
fname, lname, email
Bob, Schlumberger, bob#bob.com
Bobbette, Schlumberger
Another, Record, goeshere#email.com
As you can see, there is a missing comma on line two. This would cause an error when attempting to pull "valArray[3]" (or valArray[2], in the case of every language but mine).
I am looking for the most efficient solution to keep this error from happening. Perhaps I should check the array length, and compare it to the index we're going to attempt to pull, before pulling it. But to do this for each and every value seems inefficient. Anybody have another idea?
Our stack is ColdFusion 8/9 and MySQL 5.1. This is why I refer to the array index as [3].
There's ArrayIsDefined(array, elementIndex), or ArrayLen(array)
seems inefficient?
You gotta code what you need to code, forget about inefficiency. Get it right before you get it fast (when needed).
I suppose if you are looking for another way of doing this (instead of checking the array length each time, although that really doesn't sound that bad to me), you could wrap each line insert attempt in a try/catch block. If it fails, then stuff the failed row in a buffer (including the line number and error message) that you could then display to the user after the batch has completed, so they could see each of the failed lines and why they failed. This has the advantages of 1) not having to explicitly check the array length each time and 2) catching other errors that you might not have anticipated beforehand (maybe a value is too long for your field, for example).

LINQ: System.Data.SqlClient.SqlException: String or binary data would be truncated

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.

Resources