Simon,

On Sun, Jun 30, 2013 at 7:41 PM, Simon Slavin <slav...@bigfraud.org> wrote:

>
> On 1 Jul 2013, at 3:27am, Igor Korot <ikoro...@gmail.com> wrote:
>
> > 1. I'm trying to minimize the number of requests I'm doing to the DB.
> What
> > I need is a way to count the number of rows that the query return to me
> > prior to going thru the "sqlite3_step()".
>
> Sorry, not possible.  SQLite does not process the entire SELECT when you
> do _prepare() and /return/ the results row by row.  Each _step() command
> tells SQLite to figure out whether there is another row and, if so, what it
> is. The first time you know whether the SELECT found any rows is when you
> look at the result of the first _step().
>
> A solution is to do a
>
> SELECT count(*) WHERE <...>
>
> first, then use the result of that to figure out whether you need to do
> the proper SELECT or not.  Which is what you were probably doing before.
>

Why life is so complicated? (C) ;-)


>
> > 2. Considering the same code above, if I want to delete this row, I will
> > need another statement variable. But will it screw up the original select
> > statement?
>
> As you suspected, it is possible that it will.  Try not to modify the
> result set while you have a statement prepared.  Either _reset() or
> _finalize() it first.
>

Well I will use another statement variable as in the sample code.
My questions was: if I call delete on the record that was just retrieved in
another query will this delete affects it?

You can also refer to my Igor's reply.

Thank you.


> Simon.
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to