Yow, there's got to be an easier way to do this ...
I'm trying to create a script file that will process a table whose name
is constructed from an integer argument passed into the script file. E.g.,
$ psql -f my_script.sql -v id=24
....
DELETE FROM table_00024 WHERE ...
Here's what I came up with so far:
\set QUIET 1
\pset footer 0
\o /tmp/reset_this_id.sql
\qecho '\\set this_table `printf \'table_%.5d\'' :id '`'
\o
\i /tmp/reset_this_id.sql
\qecho :id
\qecho :this_table
So, it works, but I'm wondering if I missed an easy alternative.
--
Jeff Boes vox 269.226.9550 ext 24
Database Engineer fax 269.349.9076
Nexcerpt, Inc. http://www.nexcerpt.com
...Nexcerpt... Extend your Expertise