Is there a way to generate and directly execute query results within
psql? Essentially, I want eval within psql.
For example, a lot of us generate DDL commands using queries, like this:
=> SELECT 'GRANT SELECT ON VIEW "'||table_schema||'.'||
table_name||'" TO budget_view;'
FROM information_schema.views
WHERE table_schema='budget';
To execute such results, I do one these:
* in a shell, pipe between psqls (ie, psql -Atc 'select ...' | psql)
* within psql, execute and copy-paste
* within psql, use \g file, then \i file
* within psql, use \g |psql
I like the \g + \i option most for consistency and robustness (don't
have to specify the db connection or worry about connecting to the wrong
db), but what I really want is a hypothetical \eval to execute the query
and then execute the results.
Any such thing?
Thanks,
Reece
--
Reece Hart, http://harts.net/reece/, GPG:0x25EC91A0