Search Postgresql Archives

executing query results withing psql

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 5: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux