SQLite inserting float value

Hello everyone!

I have a problem with inserting some values into table(SQLite library). I have 3 columns, 1. is ID, second is number/value and third is just a string. Problem is that because I have float as value SQLite thinks I am sending 4 values in because float has a comma in it.

My code:

query = "INSERT INTO" +String.format(" %s VALUES(NULL, %d, '%s');", TableName, value, randomText);
    db.query(query);

What Processing is saying:

INSERT INTO VrednostiEKG VALUES(NULL, 0,23, 'Stiski?'); java.sql.SQLException: [SQLITE_ERROR] SQL error or missing database (table VrednostiEKG has 3 columns but 4 values were supplied)

Anyone knows of a solution? I could make another column and separate value float into 2 different columns but that could make things messy at the end.

Tagged:

Answers

  • Answer ✓

    Found the solution already(even tho I tried to figure it out for like an hour befure I posted discussion)

    Second column has to be REAL and in code I changed this:

    String query = "INSERT INTO" +String.format(" %s VALUES(NULL, '%5.2f' , '%s');", ImeTabele, skupnopovprecje, dogajanje);
    db.query(query);
    
Sign In or Register to comment.