pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Executing Anonymous Blocks
4+ messages / 4 participants
[nested] [flat]

* Executing Anonymous Blocks
@ 2005-03-28 07:27 imad <immaad@gmail.com>
  2005-03-28 14:43 ` Re: Executing Anonymous Blocks Alvaro Herrera <alvherre@dcc.uchile.cl>
  0 siblings, 1 reply; 4+ messages in thread

From: imad @ 2005-03-28 07:27 UTC (permalink / raw)
  To: pgsql-sql; pgsql-hackers@postgresql.org

hi,

I want to know is there any way to execute an anonymous PL/pgSQL block
in PostgreSQL.

Thanx


-- 

Regards
Imad



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Executing Anonymous Blocks
  2005-03-28 07:27 Executing Anonymous Blocks imad <immaad@gmail.com>
@ 2005-03-28 14:43 ` Alvaro Herrera <alvherre@dcc.uchile.cl>
  2005-03-29 07:59   ` Re: Executing Anonymous Blocks Neil Conway <neilc@samurai.com>
  0 siblings, 1 reply; 4+ messages in thread

From: Alvaro Herrera @ 2005-03-28 14:43 UTC (permalink / raw)
  To: imad <immaad@gmail.com>; +Cc: pgsql-sql; pgsql-hackers@postgresql.org

On Mon, Mar 28, 2005 at 12:27:18PM +0500, imad wrote:

> I want to know is there any way to execute an anonymous PL/pgSQL block
> in PostgreSQL.

No, there isn't.

-- 
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
Al principio era UNIX, y UNIX habló y dijo: "Hello world\n".
No dijo "Hello New Jersey\n", ni "Hello USA\n".



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Executing Anonymous Blocks
  2005-03-28 07:27 Executing Anonymous Blocks imad <immaad@gmail.com>
  2005-03-28 14:43 ` Re: Executing Anonymous Blocks Alvaro Herrera <alvherre@dcc.uchile.cl>
@ 2005-03-29 07:59   ` Neil Conway <neilc@samurai.com>
  2005-03-29 11:55     ` Re: Executing Anonymous Blocks Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 1 reply; 4+ messages in thread

From: Neil Conway @ 2005-03-29 07:59 UTC (permalink / raw)
  To: Alvaro Herrera <alvherre@dcc.uchile.cl>; +Cc: imad <immaad@gmail.com>; pgsql-hackers@postgresql.org

Alvaro Herrera wrote:
> On Mon, Mar 28, 2005 at 12:27:18PM +0500, imad wrote:
>>I want to know is there any way to execute an anonymous PL/pgSQL block
>>in PostgreSQL.
> 
> No, there isn't.

It might be possible to implement at least some of this functionality 
entirely in the client. So:

BLOCK;
/* your pl/pgsql code here */
END BLOCK;

Could be transformed by the client app to:

CREATE FUNCTION anon_xxx() AS '/* your pl/pgsql code here'
RETURNS void LANGUAGE 'plpgsql';
SELECT anon_xxx();
DROP FUNCTION anon_xxx();

This would be pretty limited -- you couldn't get a return value from the 
anonymous block, for example -- but I can see it being useful in some 
situations.

-Neil



^ permalink  raw  reply  [nested|flat] 4+ messages in thread

* Re: Executing Anonymous Blocks
  2005-03-28 07:27 Executing Anonymous Blocks imad <immaad@gmail.com>
  2005-03-28 14:43 ` Re: Executing Anonymous Blocks Alvaro Herrera <alvherre@dcc.uchile.cl>
  2005-03-29 07:59   ` Re: Executing Anonymous Blocks Neil Conway <neilc@samurai.com>
@ 2005-03-29 11:55     ` Andrew Dunstan <andrew@dunslane.net>
  0 siblings, 0 replies; 4+ messages in thread

From: Andrew Dunstan @ 2005-03-29 11:55 UTC (permalink / raw)
  To: neilc@samurai.com; +Cc: alvherre@dcc.uchile.cl; immaad@gmail.com; pgsql-hackers@postgresql.org

Neil Conway said:
> Alvaro Herrera wrote:
>> On Mon, Mar 28, 2005 at 12:27:18PM +0500, imad wrote:
>>>I want to know is there any way to execute an anonymous PL/pgSQL block
>>>in PostgreSQL.
>>
>> No, there isn't.
>
> It might be possible to implement at least some of this functionality
> entirely in the client. So:
>
> BLOCK;
> /* your pl/pgsql code here */
> END BLOCK;
>
> Could be transformed by the client app to:
>
> CREATE FUNCTION anon_xxx() AS '/* your pl/pgsql code here'
> RETURNS void LANGUAGE 'plpgsql';
> SELECT anon_xxx();
> DROP FUNCTION anon_xxx();
>
> This would be pretty limited -- you couldn't get a return value from
> the  anonymous block, for example -- but I can see it being useful in
> some  situations.
>

I don't see that performing the same transformation at the SQL level would
be any harder. Then if we ever got SQL host variables we might have a good
way of using them ;-). Of course, another question is whether we should make
plpgsql special, or allow anonymous blocks in any supported language.

cheers

andrew





^ permalink  raw  reply  [nested|flat] 4+ messages in thread


end of thread, other threads:[~2005-03-29 11:55 UTC | newest]

Thread overview: 4+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2005-03-28 07:27 Executing Anonymous Blocks imad <immaad@gmail.com>
2005-03-28 14:43 ` Alvaro Herrera <alvherre@dcc.uchile.cl>
2005-03-29 07:59   ` Neil Conway <neilc@samurai.com>
2005-03-29 11:55     ` Andrew Dunstan <andrew@dunslane.net>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox