"liubin liu" <[email protected]> wrote in message
news:[email protected]
> the question is on the callback function's return values of
> sqlite3_exec()
>
> when using sqlite3_exec() to do "select * from ...", how to get all
> the return values by using the callback function?
>
> it could print the result, but couldn't return the values. If do like
> so, just one value could be get.
> how to get all the values?

Memory allocated for value[] strings is valid only inside the callback. 
It is deallocated or reused as soon as the callback returns. So, you 
can't just store a pointer you receive - it'll soon become invalid. You 
need to allocate your own memory and make a copy of string contents.

Also, consider using prepared statements instead of sqlite3_exec - see 
sqlite3_prepare, sqlite3_step, sqlite3_finalize, sqlite3_column_*. For 
one thing, values of numeric fields could be retrieved directly as 
integers, rather than converted to strings and then converted back.

Igor Tandetnik



_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to