Many thanks for helping.
While using SQLite dll Version 3.3.4 on Windows - Multiple threads/processes access SQLite database, - Each thread does some SELECTs, INSERTs or UPDATEs. If for some single SELECT (where user input is used in SQL statement, so to avoid SQL injection), sqlite3_prepare()/sqlite3_bind_****()/sqlite3_step()/sqlite3_finalize() are used then in that case Q1. Which one is preferable -> BEGIN TRANSACTION or BEGIN IMMEDIATE ? Q2. In the sample code below, if I remove two statements containing "BEGIN TRANSACTION;" and "COMMIT TRANSACTION;" then for how long lock will be acquired i.e. at which point of time lock will be acquired and which point of time lock will be released ? Please throw some light on that. Thanks Rohit /* Sample code */ sqlite3* pDB; sqlite3_stmt* pStmt; char* szError = 0; char* szTail = 0; if( sqlite3_open("test.db", &pDB) != SQLITE_OK ) { printf("Couldn't open the database.\n"); exit(1); } string name; /* get from user input */ name = "ABCD"; // for testing nRet = sqlite3_exec(pDB, "BEGIN TRANSACTION;", 0, 0, &szError); <<<<<<<<<<--------------- const char* szSQL = "SELECT id, name, birthdate FROM table1 WHERE name = ?;" ; nRet = sqlite3_bind_text(mpVM, nParam, szValue, -1, SQLITE_TRANSIENT); if( sqlite3_prepare(pDB, szSQL, -1, &pStmt, &szTail) != SQLITE_OK ) throw "sqlite3_prepare Failed"; if ( sqlite3_step(pStmt) == SQLITE_DONE ) { int i=0; int empid = sqlite3_column_int(pStmt, ++i); string name = (const char*) sqlite3_column_text(pStmt, ++i); double birthdate = sqlite3_column_double(pStmt, ++i); /* print something */ std::cout << id << "-" << name << "-" << birthdate << endl; } nRet = sqlite3_finalize(pStmt); nRet = sqlite3_exec(pDB, "COMMIT TRANSACTION;", 0, 0, &szError); <<<<<<<<<<--------------- -- View this message in context: http://www.nabble.com/Multiple-SELECTs-%28and-single-SELECT%29-and-TRANSACTION---tf2072083.html#a5765261 Sent from the SQLite forum at Nabble.com.