On 09/01/2014 10:24 PM, Andres Freund wrote: > I know of format(), but it doesn't allow you to pass parameters as > actual query variables unfortunately. > I'm wondering if there's a way to marry USING and format()...
Well, the idiom:
EXECUTE format("SELECT %I FROM %I WHERE $1", col, tbl) USING val;
is not lovely. It works, but it's clumsy.
It is not intuitive, but It is well descriptive about PL/pgSQL. I cannot to imagine some different - it is mix of two independent worlds. And at end it is elegant.
If we start new language from scratch, then we don't need to introduce concept of embedded SQL or dynamic SQL.
But why? If it is too clumsy for you, use PLPerl or PLPython. Everytime will be problem how to merge two different namespaces together.