How to generate a unique progressive sequence number in a script?

Hi,
I am facing templates for the first time. How can I generate the Central User Account in the form "X" + a progressive number (the number should be retrieved from a "sequence" stored on the DB)?
Thank you