persistentstorage/sql/SRC/Server/SqlSrvStatementUtil.cpp
branchRCL_3
changeset 12 6b6fd149daa2
parent 9 667e88a979d7
child 15 fcc16690f446
equal deleted inserted replaced
11:211563e4b919 12:6b6fd149daa2
   421 //It checks the arguments and returns an error if:
   421 //It checks the arguments and returns an error if:
   422 // - aSqliteError != SQLITE_OK;
   422 // - aSqliteError != SQLITE_OK;
   423 // - aHasTail is true (possibly more than one SQL statement, separated with ";");
   423 // - aHasTail is true (possibly more than one SQL statement, separated with ";");
   424 // - aStmtHandle is NULL;
   424 // - aStmtHandle is NULL;
   425 //
   425 //
   426 static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt* aStmtHandle)
   426 static TInt ProcessPrepareError(TInt aSqliteError, TBool aHasTail, sqlite3_stmt*& aStmtHandle)
   427 	{
   427 	{
   428 	if(aSqliteError != SQLITE_OK)
   428 	if(aSqliteError != SQLITE_OK)
   429 		{
   429 		{
   430 		return ::Sql2OsErrCode(aSqliteError, sqlite3SymbianLastOsError());
   430 		return ::Sql2OsErrCode(aSqliteError, sqlite3SymbianLastOsError());
   431 		}
   431 		}
   432 	else if(aHasTail || !aStmtHandle)
   432 	else if(aHasTail || !aStmtHandle)
   433 		{//More than one SQL statement or the SQL string is "" or ";;;" or ";   ;; ;". 
   433 		{//Case 1:
   434 		 //Report it as an error, because there is no statement handle.
   434 		 // More than one SQL statement or the SQL string is "" or ";;;" or ";   ;; ;". 
       
   435 		 // Report it as an error, because there is no statement handle.
       
   436 		 //Case 2:
       
   437 		 // Non-null aHasTail. In this case the SQL string contains more than one SQL statement.
       
   438 		 // The statement handle is not null. The statement has to be finialized before reporting the error.
       
   439 		(void)FinalizeStmtHandle(aStmtHandle);
       
   440 		aStmtHandle = NULL;
   435 		return KErrArgument;
   441 		return KErrArgument;
   436 		}
   442 		}
   437 	return KErrNone;
   443 	return KErrNone;
   438 	}
   444 	}
   439 
   445