I don't think with AQL you can do that without a lua module. However the lua module is quite simple. AQL does not have the ability to utilize Operations in execute(), which is the other way you could do using, say, a Java client.
(sets ttl to argument value, in seconds)
mymodule.lua
============
function mytouch(rec, ttl_val)
record.set_ttl(rec, ttl_val)
aerospike:update(rec)
end
Now load this file to the server via AQL.
aql> register module "mymodule.lua"
OK, 1 module added.
I have 10 records, one of them is:
aql> set record_print_metadata true
aql> select * from test.testset where pk="key1"
select * from test.testset where pk="key1"
+--------+-----+--------+-------+
| name | age | {ttl} | {gen} |
+--------+-----+--------+-------+
| "Jack" | 26 | 431998 | 1 |
+--------+-----+--------+-------+
1 row in set (0.002 secs)
OK
Lets set all records ttl to 100 seconds..
aql> execute mymodule.mytouch(100) on test.testset
execute mymodule.mytouch(100) on test.testset
OK, Scan job (13085139689609506765) created.
aql> select * from test.testset where pk="key1"
select * from test.testset where pk="key1"
+--------+-----+-------+-------+
| name | age | {ttl} | {gen} |
+--------+-----+-------+-------+
| "Jack" | 26 | 98 | 2 |
+--------+-----+-------+-------+
1 row in set (0.001 secs)
OK