Please find question1 as you read along the code:
function()
{
if(sqlite3_open(ch, &database) == SQLITE_OK)
{
const char *pSQL[6];
pSQL[3] = "select * from TagValues";
sqlite3_stmt *statement, *statement4;
char* errorMessage;
CString csValue, queryStr, Tag;
if ( sqlite3_prepare(database, pSQL[3], -1, &statement, 0 ) == SQLITE_OK )
{
int ctotal = sqlite3_column_count(statement);
int res = 0;
sqlite3_exec(database, "BEGIN TRANSACTION", NULL, NULL, &errorMessage);
while ( 1 )
{
res = sqlite3_step(statement);
if ( res == SQLITE_ROW )
{
for ( int i = 0; i < 1; i++ )
{
Tag = (char*)sqlite3_column_text(statement, i);
queryStr.Format(L"update TagValues set Value='%s' where Tag='%s'", csValue, Tag);
pSQL[4] = T2A(queryStr);
sqlite3_prepare(database, pSQL[4], -1, &statement4, 0 ); }
}
if ( res == SQLITE_DONE)
{
sqlite3_exec(database, "END TRANSACTION", NULL, NULL, &errorMessage);
}
}
}
}
}
Its taking 2 seconds to update 400 entries of pSQL[4]. Please suggest me. If i remove both end and begin transactions, the time is still the same.