If your template parameter bindings are bidirectional, you could simply reuse them to build your query arguments. Here is an example script that does this:
repeater = event.source.parent.getComponent('Template Repeater')
for template in repeater.getLoadedTemplates():
arguments = []
for customProperty in template.dynamicProps:
arguments.append(template.getPropertyValue(customProperty))
print arguments #use these arguments for your UPDATE query
Edit: replaced getTemplates function with built in method for getting loaded templates