psql command line tool allows us to ask for input from user or to set some values from command line.
- asking for value can be done by command “\prompt” – here is a full example of a script – http://manojadinesh.blogspot.de/2013/11/interactive-postgresql-script.html
- setting variable can be done either by command “\set” or by command line parameter ” -v variable=value ” during psql start – see here – http://stackoverflow.com/questions/7389416/postgresql-how-to-pass-parameters-from-command-line
in both cases variable is accessible in program as “:variable”