How to assign a lua variable to sqlite table

Hi All,

I want to assign a lua variable to sqlite table. I am using the following statement

db:exec[[update mytable set pno=x where id=1;]]

where ‘x’ is a lua variable having integer value and this is not working however if I replace x with a number it works.

Please help me how can I pass lua variable to sqlite.

Thanks [import]uid: 126619 topic_id: 32453 reply_id: 332453[/import]

I am using regular string when working with sqlite - easier :slight_smile:

 local tablesetup = "update mytable set pno=" .. x .. " where id=1";  
 db:exec( tablesetup );  

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129053[/import]

Good answer Joakim [import]uid: 19626 topic_id: 32453 reply_id: 129067[/import]

Hi
thanks for help. But it is not working. can you please come up with solution. I will be thankful.

[import]uid: 126619 topic_id: 32453 reply_id: 129071[/import]

  1. How does your database look like? Have you the correct types on each field? Did you design it by code or are you using some GUI?

  2. Please post us some more code, it is easier to see whats going on.

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129073[/import]

@ robmiracle, thank you!

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129074[/import]

I am using regular string when working with sqlite - easier :slight_smile:

 local tablesetup = "update mytable set pno=" .. x .. " where id=1";  
 db:exec( tablesetup );  

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129053[/import]

Good answer Joakim [import]uid: 19626 topic_id: 32453 reply_id: 129067[/import]

Hi
thanks for help. But it is not working. can you please come up with solution. I will be thankful.

[import]uid: 126619 topic_id: 32453 reply_id: 129071[/import]

  1. How does your database look like? Have you the correct types on each field? Did you design it by code or are you using some GUI?

  2. Please post us some more code, it is easier to see whats going on.

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129073[/import]

@ robmiracle, thank you!

Joakim [import]uid: 81188 topic_id: 32453 reply_id: 129074[/import]