My function fun() returned a long crosstab table generation string (varchar) that I can view with select fun(). How to execute it not inside a function but from a console?
Asked
Active
Viewed 1,456 times
2
Blender
- 75
- 9
1 Answers
3
Use \gexec in psql to execute what the query returns:
SELECT fun()\gexec
The manual:
Sends the current query buffer to the server, then treats each column of each row of the query's output (if any) as an SQL statement to be executed.
Read the manual for more details.
Related:
Erwin Brandstetter
- 185,527
- 28
- 463
- 633