When you write a custom tag, you can do pretty much anything you want. We have written a custom <sqlplus> tag for Oracle that allows you to run the sqlplus command line tool, which allows for the kinds of things you are talking about. Doing something similar for the psql scripting language wouldn't be too difficult. There is also the <executeCommand> change tag, which isn't well documented, but might work for you. It looks something like this:
Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/
<executeCommand executable="./execphp" os="Linux">
<arg value="Add50SO.php"/>
</executeCommand>
Steve Donie
Principal Software Engineer
Datical, Inc. http://www.datical.com/