Unix Technical Forum

Executing Anonymous Blocks

This is a discussion on Executing Anonymous Blocks within the pgsql Hackers forums, part of the PostgreSQL category; --> hi, I want to know is there any way to execute an anonymous PL/pgSQL block in PostgreSQL. Thanx -- ...


Go Back   Unix Technical Forum > Database Server Software > PostgreSQL > pgsql Hackers

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-11-2008, 04:15 AM
imad
 
Posts: n/a
Default Executing Anonymous Blocks

hi,

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

Thanx


--

Regards
Imad

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-11-2008, 04:15 AM
Alvaro Herrera
 
Posts: n/a
Default Re: Executing Anonymous Blocks

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".

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
subscribe-nomail command to majordomo@postgresql.org so that your
message can get through to the mailing list cleanly

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-11-2008, 04:15 AM
Neil Conway
 
Posts: n/a
Default Re: Executing Anonymous Blocks

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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 04-11-2008, 04:15 AM
Andrew Dunstan
 
Posts: n/a
Default Re: Executing Anonymous Blocks

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



---------------------------(end of broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to majordomo@postgresql.org

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 04:31 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com