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

From: Jasen Betts <jasen(at)xnet(dot)co(dot)nz>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Any way to execute ad-hoc pl/pgsql?
Date: 2009-05-01 10:56:29
Message-ID: gtekgt$ksp$3@reversiblemaps.ath.cx
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 2009-05-01, Carlo Stonebanks <stonec(dot)register(at)sympatico(dot)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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Jasen Betts 2009-05-01 11:05:29 Re: Connecting to a postgreSQL database with windows CE over wi-fi; failing gracefully
Previous Message Daniel Verite 2009-05-01 10:34:10 Re: Importing large objects from the client side programatically.