## Example: Updating TTL

This example demonstrates an update of the expiration time of a row. Let’s assume that the People table was created with a TTL value of 10 hours and a row with id 5 was inserted at time 2017-06-01T10:05:30.0. No explicit TTL was given at insertion time, so the expiration time computed at that time is 2017-06-01T21:00:00.0. Finally, let’s assume that the following update statement is executed at time 2017-06-01T12:35:30.0 (2.5 hours after insertion)

```
UPDATE People $p
SET TTL remaining_hours($p) + 3 hours
WHERE id = 5;
```

The above statement extends the life of a row by 3 hours. Specifically, the remaining_hours function returns the number of full hours remaining until the expiration time of the row. See integer remaining_hours(AnyRecord) function. In this example, this number is 8. So, the new TTL value is 8+3 = 11, and the expiration time of the row will be set to 2017-06-02:T08:00:00.0.

Notice the use of the '$' character in naming the table alias for People. This is required so that the table alias acts as a row variable (a variable ranging over the rows of the table) and as a result it can be passed as the argument to the remaining_hours function (if the $ were not used, then calling remaining_hours(p) would return an error, because p is interpreted as a reference to a top-level table column with name "p").