Solved

SQLite: What is wrong with my query?

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
SQL Command Tool comes with APEX under SQL Workshop. It helps us to make changes on the database directly using a graphical user interface. This helps us writing any SQL/ PLSQL queries and execute it on the database and we can create any database ob…
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…

757 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

16 Experts available now in Live!

Get 1:1 Help Now