X-Original-To: pgsql-interfaces-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 9C92D53580 for ; Thu, 5 May 2005 18:49:35 -0300 (ADT) 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 68699-06 for ; Thu, 5 May 2005 21:49:32 +0000 (GMT) Received: from hotmail.com (bay10-f1.bay10.hotmail.com [64.4.37.1]) by svr1.postgresql.org (Postfix) with ESMTP id 7839653488 for ; Thu, 5 May 2005 18:49:31 -0300 (ADT) Received: from mail pickup service by hotmail.com with Microsoft SMTPSVC; Thu, 5 May 2005 14:49:45 -0700 Message-ID: Received: from 62.178.117.119 by by10fd.bay10.hotmail.msn.com with HTTP; Thu, 05 May 2005 21:49:44 GMT X-Originating-IP: [62.178.117.119] X-Originating-Email: [seppwimmer@hotmail.com] X-Sender: seppwimmer@hotmail.com From: "Robert Wimmer" To: pgsql-interfaces@postgresql.org Subject: dynamic functions Date: Thu, 05 May 2005 21:49:44 +0000 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1; format=flowed X-OriginalArrivalTime: 05 May 2005 21:49:45.0144 (UTC) FILETIME=[59C0DB80:01C551BC] X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.241 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, MSGID_FROM_MTA_HEADER, UPPERCASE_25_50 X-Spam-Level: * X-Archive-Number: 200505/23 X-Sequence-Number: 5526 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/