From: Robert Wimmer <seppwimmer@hotmail.com>
To: pgsql-interfaces@postgresql.org
Subject: dynamic functions
Date: Thu, 05 May 2005 21:49:44 +0000
Message-ID: <BAY10-F1223F44B77E5F515A0B5AD01A0@phx.gbl> (raw)
hi ,
is there any way to build "dynamic functions" in plpgsql ?
my problem is, i have a table defining attributes like
CREATE TABLE attribute.attribute (
name NAME PRIMARY KEY,
descr VARCHAR(256),
regex VARCHAR(50) NOT NULL,
minlen INTEGER NOT NULL DEFAULT 0,
maxlen INTEGER NOT NULL DEFAULT 64
-- validate NAME // not implemented
);
and a function like
CREATE OR REPLACE FUNCTION
attribute.match(TEXT,TEXT,BOOLEAN) RETURNS INTEGER AS '
.. check the value (against the regex etc) ..
END; ' LANGUAGE plpgsql
in some cases i would like to check the values also against a function for
example
CREATE FUNCTION attribute.check_range(TEXT) RETURNS INTEGER AS '
BEGIN
IF $1 ... THEN RETURN -1; END IF;
RETURN 0;
END; '
....
so that i can do the following in my match function
CREATE OR REPLACE FUNCTION
attribute.match(TEXT,TEXT,BOOLEAN) RETURNS INTEGER AS '
.. check the value (against the regex etc) ..
IF attrib.validate NOT IS NULL THEN
cmd := atrib.validate || ''('' $1 '')'' ||;
-- ??
-- EXECUTE ''SELECT '' || cmd; // SELECT does not work in EXECUTE
-- ??
END IF
END; ' LANGUAGE plpgsql
is there a way to get a result back from EXECUTE ?
i hope you can understand my description of the problem
i am using postgresQL 7.4 on debian
thanx
sepp
_________________________________________________________________
Recherchieren Sie auf eigene Faust mit der wohl besten Suchmaschine im Netz.
http://search.msn.at/
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-interfaces@postgresql.org
Cc: seppwimmer@hotmail.com
Subject: Re: dynamic functions
In-Reply-To: <BAY10-F1223F44B77E5F515A0B5AD01A0@phx.gbl>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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