Actually that's where I
started. Most of the answers on StackOverflow either don't work on the
latest versions of PostgreSQL or didn't include the complete DDL. Most
were missing indices and constraints. As a previous poster remarked,
psql -E and then copy/pasting and using that as the basis for custom
function(s) seems to be my only path forward.
a shame that users are basically forced to write not entirely
simplistic SQL themselves. The SQL appears to already exist in
PostgreSQL as evidenced by the results of psql -E, it just doesn't seem
that it was packaged into user accessible SQL functions. I've noticed
that the answer to many questions seem to be "use this psql \ command".
Is there any reason that all of the special psql magic functions
couldn't be exposed as default SQL functions?
well. Thanks for all the help.