Updating a query from a table

You're not passing any parameters to your query, so it just sends nulls instead.
You need to pass a dict containing keys that match your query parameters:

params = {
  'Trailer': value_for_trailer,
  'Batch': value_for_batch
}
system.db.runNamedQuery(query, params)

Also, take a look at this: