SQL LITE Update
(1) By anonymous on 2020-04-18 20:46:24 [source]
I have an SQL statement Database.executeUpdate("UPDATE RequestTable SET SupplyAmt = '"+intreqID1+"' WHERE ID='1-HS'"); which is supposed to add the number 10 that is in my intreqID1 in my RequestTable in DBBrowser but it does not. How do I make sure that the number shows in the table?
(2) By Simon Slavin (slavin) on 2020-04-18 21:14:00 in reply to 1 [link] [source]
intreqID1 is a number you don't need the apostrophes around it.
Can you insert a line into your program that prints out the SQL statement you're trying to execute ? I want to know whether the correct value is being inserted for
Also can you execute
SELECT COUNT(*) FROM RequestTable WHERE ID='1-HS' ?
(3) By Larry Brasfield (LarryBrasfield) on 2020-04-18 21:18:00 in reply to 1 [link] [source]
I'm guessing that you meant to do something resembling the following session:
sqlite> create table r (id int, sa real); sqlite> insert into r values (1, 1.0); sqlite> insert into r values (2, 2.0); sqlite> update r set sa = sa+10 where id=2; sqlite> select * from r; id sa 1 1.0 2 12.0 sqlite>
One problem with what you wrote is that your expression to which SupplyAmt is being set is merely a literal string. It specifies no arithmetic. Contrast that with the 4th line in above session screen-scrape.