I've started to use the "here document" idea a lot when writing scripts to do tasks.
#!/usr/local/bin/bash
psql -d myDB <<EOSQL
select foo ....
update bar;
delete from ...
EOSQL
Bob
This message has been scanned but we cannot guarantee that it and any
attachments are free from viruses or other damaging content: you are
advised to perform your own checks. Email communications with the
University of Nottingham may be monitored as permitted by UK legislation.