3

hi I m using the following code to generate a table on sqlite manager.

CREATE TABLE Transaction (ID PRIMARY KEY , amount REAL , currencyCode CHAR(3) , comments VARCHAR , debitAccount INTEGER , creditAccount INTEGER , debitAccountExchangeRate REAL , creditAccountExchangeRate REAL , FOREIGN KEY (currencyCode)REFERENCES Currency (code) , FOREIGN KEY (debitAccount) REFERENCES Account  (ID) , FOREIGN KEY (parentAccount) REFERENCES Account (ID ));

but I am getting the syntax error. Can any one please specify what am i doing wrong here.

    [ near "Transaction": syntax error ]
    Exception Name: NS_ERROR_FAILURE
      Exception Message: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE)      [mozIStorageConnection.createStatement]

3 Answers 3

4

Try this..

CREATE TABLE "Transaction" (ID PRIMARY KEY , amount REAL , currencyCode CHAR(3) , comments VARCHAR , debitAccount INTEGER , creditAccount INTEGER , debitAccountExchangeRate REAL , creditAccountExchangeRate REAL , FOREIGN KEY (currencyCode)REFERENCES Currency (code) , FOREIGN KEY (debitAccount) REFERENCES Account  (ID) , FOREIGN KEY (creditAccount) REFERENCES Account (ID ));
Sign up to request clarification or add additional context in comments.

Comments

4

I was having a similar issue and, believe it or not, just changing my table name to "TRANSACTIONS" worked for me. "Transaction" must a reserved word in SQLite, but I know the error message I got was far from helpful.

Hope that helps.

Comments

1

I got this error because I forgot to separate the columns in my query with commas. I guess it doesn't like that.

I was doing:

SELECT Col1 Col2 Col3 FROM Table1

SQLite was expecting:

Select Col1, Col2, Col3 FROM Table1

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.