Hi, ALL,
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. It's
not an error situation, it just means that there was no new records
inserted with specific constraints.
An example:
if( ( result = sqlite3_prepare_v2( m_handle, "SELECT pplayerid FROM players
WHERE players.isnew=\"1\";", -1, &stmt, 0 ) != SQLITE_OK )
{
// display error message
}
else
{
//////// check the number of rows returned by the query
if( numRows == 0 )
return;
else
{
sqlite3_step( stmt );
sqlite3_finalize( stmt );
}
}
Is there such a function? There is a "sqlite3_column_count()", but it will
return number of columns in the result set, which I assume will always be 1
in my case (if there is no errors of course).
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:
int playerid;
if( ( result = sqlite3_prepare_v2( m_handle, "SELECT pplayerid FROM players
WHERE players.isnew=\"1\";", -1, &stmt, 0 ) != SQLITE_OK )
{
// display error message
}
else
{
//////// check the number of rows returned by the query
if( numRows == 0 )
return;
else
{
while( true )
{
sqlite3_step( stmt );
playerid = sqlite3_column_int( stmt, 0 );
if( ( result = sqlite3_prepare_v2( m_handle, "DELETE FROM players
WHERE playerid = ?;", -1, &stmt1, 0 ) != SQLITE_OK )
{
//error message
}
else
{
sqlite3_step( stmt1 ); // at this point the outer cursor
will still be good, right?
sqlite3_finalize( stmt1 );
}
}
sqlite3_finalize( stmt );
}
Thank you.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users