a way to generate functions dynamically ?

From: "Marc Mamin" <M(dot)Mamin(at)intershop(dot)de>
To: <pgsql-sql(at)postgresql(dot)org>
Subject: a way to generate functions dynamically ?
Date: 2007-01-11 08:29:56
Message-ID: CA896D7906BF224F8A6D74A1B7E54AB30175095D@JENMAIL01.ad.intershop.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hello,

I need to generate some procedures that depend data models stored in my
DBs.
As I have different models in different databases, the stored procedures
will differ.

My idea is to generate the required stored procedures dynamically once a
model is defined.
I will probably do this within the application. But is there a way to
achieve this with plpgsql ?

here a naive try to illustrate my idea:

CREATE OR REPLACE FUNCTION test(p1 int)
RETURNS integer AS
$BODY$

EXECUTE'

CREATE OR REPLACE FUNCTION generated(p2 int)
RETURNS integer AS

$BODY$

BEGIN
return p2 + ' || p1 || ';
END;

$BODY$

LANGUAGE ''plpgsql'' VOLATILE
';

ERROR: syntax error at or near "BEGIN"
SQL state: 42601
Character: 156


Thanks,

Marc

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Huxton 2007-01-11 10:19:57 Re: a way to generate functions dynamically ?
Previous Message Chad Wagner 2007-01-11 00:38:38 Re: How to aggregates this data