X-Original-To: pgsql-hackers-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id E6FBD53A5B for ; Tue, 29 Mar 2005 08:59:56 +0100 (BST) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 45117-06 for ; Tue, 29 Mar 2005 07:59:52 +0000 (GMT) Received: from mailbox.samurai.com (mailbox.samurai.com [205.207.28.82]) by svr1.postgresql.org (Postfix) with ESMTP id 389B3536D5 for ; Tue, 29 Mar 2005 08:59:51 +0100 (BST) Received: from localhost (mailbox.samurai.com [205.207.28.82]) by mailbox.samurai.com (Postfix) with ESMTP id D999D18CF87; Tue, 29 Mar 2005 02:59:51 -0500 (EST) Received: from mailbox.samurai.com ([205.207.28.82]) by localhost (mailbox.samurai.com [205.207.28.82]) (amavisd-new, port 10024) with LMTP id 61527-01-2; Tue, 29 Mar 2005 02:59:49 -0500 (EST) Received: from [61.88.101.19] (unknown [61.88.101.19]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mailbox.samurai.com (Postfix) with ESMTP id A053418CC12; Tue, 29 Mar 2005 02:59:48 -0500 (EST) Message-ID: <42490AF0.6040704@samurai.com> Date: Tue, 29 Mar 2005 17:59:44 +1000 From: Neil Conway User-Agent: Debian Thunderbird 1.0 (X11/20050116) X-Accept-Language: en-us, en MIME-Version: 1.0 To: Alvaro Herrera Cc: imad , pgsql-hackers@postgresql.org Subject: Re: Executing Anonymous Blocks References: <1f30b80c0503272327502a34a9@mail.gmail.com> <20050328144335.GB3574@dcc.uchile.cl> In-Reply-To: <20050328144335.GB3574@dcc.uchile.cl> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: by amavisd-new at mailbox.samurai.com X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.03 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200503/1010 X-Sequence-Number: 65812 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