SQL issues

Hi guys

I’ve got 2 issues at the minute with some code that I’ve got.

Here’s the first one:

  
local row = row.id  
  
local updateTable = "UPDATE Options SET option1=1 WHERE id="..row"  
db:exec( updateTable )  
  

The code above is incorrect and I get an error eveytime. The cause seems to be the way that “…row” has been written but I’ve tried every possible way but can’t seem to figure it out.

The second issue is that is there any way to reflect the change immediately? Everything is mainly Database based so I’d imagine I’d have to run a query to retrieve the updated information?

Ideally I don’t want to keep constantly running queries should the player decide they want to update many options at once! [import]uid: 40538 topic_id: 13086 reply_id: 313086[/import]

first thing…
there should not be a " after the …row

local updateTable = “UPDATE Options SET option1=1 WHERE id=”…row"
should be
local updateTable = “UPDATE Options SET option1=1 WHERE id=”…row

not sure what you are doing with local row = row.id

better to use a different variable name
e.g. local idtofind = row.id
local sql = “UPDATE Options SET option1=1 WHERE id=”…idtofind
db:exec( sql ) [import]uid: 49842 topic_id: 13086 reply_id: 48106[/import]

That fixed it! - thanks

(I think “row” may be some kind of reserved word…)
Now for the second issue - am I be able to reflect these changes in realtime without querying the database again, as when the screen loads I already query the database once to retrieve the current option values.
Cheer again [import]uid: 40538 topic_id: 13086 reply_id: 48201[/import]

when the db:exec( sql ) line runs, all it is doing is updating the database. If you want the value change to be reflected in your game then you can either, pull the value from the database (again), or probably more simple to set the value in your game at the same time as updating the database.
Had to type this quick as my UPS is beeping and my computer is about to shut down;-) [import]uid: 49842 topic_id: 13086 reply_id: 48203[/import]

Hope you manage to get your computer sorted!

Just a quick question, what do you mean by “set the value in your game at the same time as updating the database” - which value am I setting?

The option value is contained within a database and is retrieved at the start and then the options are then displayed using a For loop.
Cheers!

[import]uid: 40538 topic_id: 13086 reply_id: 48224[/import]

when you read the options from the database, you are then setting some options based on what you read, yes?
Just set those options to the new value. [import]uid: 49842 topic_id: 13086 reply_id: 48227[/import]