On Sun, Jun 30, 2013 at 7:47 PM, Igor Tandetnik <i...@tandetnik.org> wrote:

> On 6/30/2013 10:27 PM, Igor Korot 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()".
>> If this number is 0, I want to skip the processing and just return.
>>
>
> How is this different from just calling sqlite3_step, seeing it return
> SQLITE_DONE right away, and getting out of the loop?


Well I'm not familiar with SQLite internals, but one thing for sure:
why go thru the process if you can avoid it?


>
>
>  //////// check the number of rows returned by the query
>> if( numRows == 0 )
>>       return;
>> else
>> {
>> sqlite3_step( stmt );
>> sqlite3_finalize( stmt );
>> }
>>
>
> This leaks a statement handle. Make it
>
> if (sqlite_step(stmt) == SQLITE_ROW) {
>   // Process the row
>
> }
> sqlite3_finalize( stmt );
>

Yes, it just a sample code. ;-)


>
>  Is there such a function?
>>
>
> No there is not.
>
>
>  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? Something like this:
>>
>
> Just run this statement;
>
> DELETE FROM players WHERE players.isnew="1";
>
> You are making it way too complicated.
>

I wish.
I need to remove those records from another table as well. That's why I
need to retrieve playerid first.
So once again: will the delete affect the outer looping SQLite statement?

Thank you.


> --
> Igor Tandetnik
>
>
> ______________________________**_________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-**bin/mailman/listinfo/sqlite-**users<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