Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 4FEFF63294D for ; Mon, 1 Mar 2010 18:39:44 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 40336-08 for ; Mon, 1 Mar 2010 22:39:33 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail.akn.me (mail.akn.me [188.40.171.129]) by mail.postgresql.org (Postfix) with ESMTP id 91A126327ED for ; Mon, 1 Mar 2010 18:39:33 -0400 (AST) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.akn.me (Postfix) with ESMTP id D28E34881518; Mon, 1 Mar 2010 23:24:42 +0100 (CET) X-Virus-Scanned: amavisd-new at akn.me Received: from mail.akn.me ([127.0.0.1]) by localhost (mail.akn.me [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xNUBqFXaFCYT; Mon, 1 Mar 2010 23:24:37 +0100 (CET) Received: from [192.168.2.145] (213.37.99.4.dyn.user.ono.com [213.37.99.4]) by mail.akn.me (Postfix) with ESMTP id A51D24881517; Mon, 1 Mar 2010 23:24:37 +0100 (CET) Message-ID: <4B8C41D6.70201@venaver.info> Date: Mon, 01 Mar 2010 23:38:14 +0100 From: Petru Ghita User-Agent: Thunderbird 2.0.0.23 (Windows/20090812) MIME-Version: 1.0 To: Gianvito Pio CC: pgsql-sql@postgresql.org Subject: Re: Create functions using a function References: <5eca56861003011350pdc14fa5l2498c260bf68a90c@mail.gmail.com> In-Reply-To: <5eca56861003011350pdc14fa5l2498c260bf68a90c@mail.gmail.com> X-Enigmail-Version: 0.96.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/8 X-Sequence-Number: 33715 -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Yes, it's possible. Use EXECUTE. There is one example under "Example 38-9. Porting a Procedure from PL/SQL to PL/pgSQL" http://www.postgresql.org/docs/8.4/static/plpgsql-porting.html Also have look in: http://www.postgresql.org/docs/8.2/static/plpgsql-statements.html under "37.6.5. Executing Dynamic Commands" Petru Ghita Gianvito Pio wrote: > Hi all, is there a way to define functions and/or triggers in a > function? > > For example, can I create a function that takes an argument and > defines a function that has the name passed as argument to the > first function? > > Something like this ..... > > CREATE FUNCTION test (name varchar) RETURNS VOID AS $$ BEGIN CREATE > FUNCTION name ( ) (here "name" should be expanded to the variable > content) RETURNS .... ... > > END $$ > > Is there a way to do this? Thanks > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkuMQdYACgkQt6IL6XzynQSjoQCffcPZ2W69uy3wpGlkhkraQm2a p0IAnA+8njdC6nAdpdhaTg/M9QEohYVb =/tvu -----END PGP SIGNATURE-----