Solved

SQLite: What is wrong with my query?

Posted on 2013-01-03
3
428 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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Never store passwords in plain text or just their hash: it seems a no-brainier, but there are still plenty of people doing that. I present the why and how on this subject, offering my own real life solution that you can implement right away, bringin…
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…

943 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now