lundi 26 octobre 2015

How to assign the same field value to several records in SQLite?

I am working with a database of waypoints produced by a GPS system mounted on a truck.

The GPS produces waypoints on a timely manner, amounting to lots of records (1 waypoint=1 record). If truck is still waypoints come at a rate; if truck is moving the rate is much higher.

GPS output is a database with a significant amount of records, each one containing at least the following fields:

 Date-time, Status, Longitude, Latitude

I need to design a query that adds (or updates) a field "Route", setting its value per the coordinates of each way point (Long, Lat).

To illustrate this with an example: I need to be able to identify, out of 500,000 waypoints (records) that the GPS produced for a month, that from record ...5,232 to record 11,354, the truck was covering Route 1 (that is, the field "Route" for all these records is set to "Route 1" after query runs); from record 11,355 to 11,735, truck was parked at origin ("Route" = "parked"); from record 11,736 to 17,303, truck was covering Route 5 ("Route" = "Route 5"). An so on...

My preliminary research indicates that this could be done with triggers, but my programming experience doesn't span that far.

Aucun commentaire:

Enregistrer un commentaire