Re: Executing dynamic queries without functions / procedures

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Nicholas Bott <zordiac(at)zordiac(dot)com>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: Executing dynamic queries without functions / procedures
Date: 2007-05-12 03:58:38
Message-ID: 13099.1178942318@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Nicholas Bott <zordiac(at)zordiac(dot)com> writes:
> I would like to use the PL language in conjunction with conditional
> statements, outside of a procedure or function. This doesn't seem to be
> possible from what I've read so far and I wanted to confirm.

Correct.

> Also, if it's not natively possible - is there some kind of hack? For
> example, creating temporary procedures to establish the same result,
> then removing them periodically?

That's basically what you've got to do. There've been discussions on
and off about providing a direct command to execute an anonymous,
transient PL function definition, along the lines of

PERFORM 'begin
... blah blah ...
end'
LANGUAGE plpgsql;

but no one's really put forward a complete plan to deal with this
(what about arguments and a return value?).

Note that there is approximately 0 interest in promoting any one
PL to the exclusion of others, so a command syntax that presumes
which PL is to be executed isn't going to happen any time soon.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Dusan PESL 2007-05-12 08:26:17 problem - group by
Previous Message Nicholas Bott 2007-05-11 23:45:29 Executing dynamic queries without functions / procedures