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]
Hadi
  • 1,212
  • 2
  • 17
  • 31

3 Answers3

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.

Dan
  • 41
  • 2
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 ));
Hadi
  • 1,212
  • 2
  • 17
  • 31
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
Thick_propheT
  • 1,003
  • 2
  • 10
  • 29