From: "Craig Longman" <craigl@begeek.com>
> but... one thing i do like about the db2 app, is that on the cmd-line i
> can specify two things:
>
> 1) stop on error
> this seems to be doable through the env-var ON_ERROR_STOP, but i do wish
> it was also parm i could pass on the cmd-line to psql. its just so much
> easier than setting the everytime i want the stop behaviour. i guess i
> could just set it and leave it.
Wrap psql in a 2-line shellscript which sets the env-var for you.
> 2) wrap a file in an explicit transaction
[snipped]
> is 2) possible right now? i can't see anything in the docs, so i think
> not. anyway, having this sort of control would really help. our
> scripts need to run on various servers, and some things use different
> syntax for transactions, db2 is 'rollback/commit work'.
Bit trickier this one. I'd do it in perl (you can probably do it in shell,
but I'm not good enough). Steps would be:
1. parse command-line parameters
2. open pipe to psql with all parameters except "-f filename" (if there)
3. write "BEGIN;" to psql
4. WHILE not EOF read STDIN/file listed on command-line
5. write "COMMIT;" to psql
With the appropriate error-checking etc.
HTH
- Richard Huxton