diff -r 211563e4b919 -r 6b6fd149daa2 persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp --- a/persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp Wed Apr 14 17:46:32 2010 +0300 +++ b/persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp Tue Apr 27 18:25:57 2010 +0300 @@ -423,15 +423,21 @@ // - aHasTail is true (possibly more than one SQL statement, separated with ";"); // - aStmtHandle is NULL; // -static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt* aStmtHandle) +static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt*& aStmtHandle) { if(aSqliteError != SQLITE_OK) { return ::Sql2OsErrCode(aSqliteError, sqlite3SymbianLastOsError()); } else if(aHasTail || !aStmtHandle) - {//More than one SQL statement or the SQL string is "" or ";;;" or "; ;; ;". - //Report it as an error, because there is no statement handle. + {//Case 1: + // More than one SQL statement or the SQL string is "" or ";;;" or "; ;; ;". + // Report it as an error, because there is no statement handle. + //Case 2: + // Non-null aHasTail. In this case the SQL string contains more than one SQL statement. + // The statement handle is not null. The statement has to be finialized before reporting the error. + (void)FinalizeStmtHandle(aStmtHandle); + aStmtHandle = NULL; return KErrArgument; } return KErrNone;