PostgreSQL and eval()
PostgreSQL and eval()
От:
Mark Morgan Lloyd <markMLl.pgsql-general@telemetry.co.uk>
Дата:
I had to do some repeated ad-hoc queries yesterday for a report that was needed in a hurry, and found myself doing repeated editing of an embedded function name. If one wants to store the name of a function in a table for subsequent use in customised queries is the only way to use it by coding an eval() function using PL/pgSQL's execute? I appreciate that I could create a function on the fly as a wrapper of the one that was to be called, but again that takes manual editing. Alternatively I appreciate that I could use PL/pgSQL but that would assume that if I sent the sequence of operations to somebody else that he also had it compiled into his server. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]
Re: PostgreSQL and eval()
От:
Mark Morgan Lloyd <markMLl.pgsql-general@telemetry.co.uk>
Дата:
Richard Huxton wrote: > Mark Morgan Lloyd wrote: >> Alternatively I appreciate that I could use PL/pgSQL but that would >> assume that if I sent the sequence of operations to somebody else that >> he also had it compiled into his server. > > Well, pl/pgsql has been automatically included in all recent version of > PG. You might have to issue "CREATE LANGUAGE plpgsql" in the database > first (permissions might be an issue I suppose) but that's all. Thanks, I'd forgotten it was built by default. -- Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]