Solved

SQLite: What is wrong with my query?

Posted on 2013-01-03
3
433 Views
Last Modified: 2013-01-24
What is wrong with my query for SQLite?

I have attached the database and the query.
q.txt
forex.txt
0
Comment
Question by:hankknight
  • 2
3 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 38741893
I have not looked at the database, but the INSERT query appears to be using double quotes (") to identify columns as well as literal data. If your columns do not use reserved words or spaces, I would drop the quotes. Moreover, the literal values should be using single quotes (') if I am not mistaken.

P.S. the number of columns looked suspect to me, but I did not mention anything. However, I just had a chance to download the database and a simple SELECT from the trades table yields the following error.
Error: malformed database schema (trades) - too many columns on trades
Therefore, you may have multiple issues going on. In fact, this may be the main error. Single quotes are the typical delimiter for literals—at least for those of us who also use SQL Server. However, I tried the following simple test in a new database.
CREATE TABLE "trades2"(
    "OpenedTime" INTEGER,
    "Touched" INTEGER,
    "Size" REAL,
    "MarginLevel" REAL,
    "Pair" TEXT,
    "Balance" REAL
);

Open in new window

INSERT INTO "trades2" (
    "OpenedTime",
    "Touched",
    "Size",
    "MarginLevel",
    "Pair",
    "Balance"
) VALUES (
    "1357251341",
    "1357251341",
    "-0.67",
    "15660.100690485",
    "GBPCHF",
    "1000108.29"
);

Open in new window

Everything worked fine. When I try the same two queries in your database I get the error above even though I am not querying the trades table. It appears it corrupts the entire database, which makes sense as the error is regarding the schema.
0
 
LVL 16

Author Comment

by:hankknight
ID: 38742060
I don't think that the problem is because there are too many columns.

The database works, it just won't take my SQL to insert additional items.

Please test the attached database, thanks.
q2.txt
forexWorkingDB.txt
0
 
LVL 59

Accepted Solution

by:
Kevin Cross earned 500 total points
ID: 38742744
I am running Windows 7 Professional 64-bit. Whenever I download the database and try to run a simple SELECT statement I get the error I displayed above. Therefore, I am unable to offer other suggestions unless you can provide information on the error you get. What exactly is going wrong on your system?

EDIT: did you try my smaller query? Did it work? Just trying to get a baseline for what works and what doesn't.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article describes some very basic things about SQL Server filegroups.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question