Re: Any way to execute ad-hoc pl/pgsql? - Mailing list pgsql-general

From Jasen Betts
Subject Re: Any way to execute ad-hoc pl/pgsql?
Date
Msg-id gtekgt$ksp$3@reversiblemaps.ath.cx
Whole thread Raw
In response to Any way to execute ad-hoc pl/pgsql?  ("Carlo Stonebanks" <stonec.register@sympatico.ca>)
List pgsql-general
On 2009-05-01, Carlo Stonebanks <stonec.register@sympatico.ca> wrote:

> One of our developers asked me, "is there any way to execute arbitrary
> plpgsql"? By that I beleive he means: is there some way to execute ad-hoc
> pl/pgsql code without creating a stored procedure or a function?

no.  arbitrary SQL is no problem,
arbitrary plpgsql must be declared as a function so that it can be
compiled and run. (compiling is automatic)


inside a function execute can be used but not all plpgsql can be
executed (but, again, you can use execute to define and run a new function)

> I believe MS SQL Server can do this - has any one heard of some sort of
> command shell to do this for PG?

> (I suppose one possibility would be something that created a temporary
> stored proc to execute the code, then cleaned up after itself.)

You seem to be wanting something like "anonymous functions". postgres
doesn't do them yet. It may in the future, or they may be incompatible
with the design.

pgsql-general by date:

Previous
From: Jasen Betts
Date:
Subject: Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully
Next
From: Craig Ringer
Date:
Subject: Re: Any way to execute ad-hoc pl/pgsql?