If you only want to put the data in the database when it has changed, then each time you read it save it in a variable. Next time you read the data compare it with the previous saved data and only put it in your database if it has changed.
Note, however, that the data from the GPS may fluctuate slightly on each read even if the unit has not moved. You might like to consider only putting it in the database if it has changed by a significant amount. Something like this
if abs( (newData - prevData) ) > 10)
//code to put the data in the database