pl/pgsql Composite Parameter Question

From: <cnliou(at)eurosport(dot)com>
To: <pgsql-general(at)postgresql(dot)org>
Subject: pl/pgsql Composite Parameter Question
Date: 2002-01-21 04:19:36
Message-ID: 200201210419.2467@th00.opsion.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Dear all,

Because pl/pgsql accepts at most 16 parameters, I am
trying to feed pl/pgsql function with the whole
record as its parameter.
"Example 24-4. A PL/pgSQL Function on Composite Type"
says I am allowed to do that but I get the error:

mydb=# insert into test values('a');
ERROR: NEW used in non-rule query

What key points have I missed? Please!

CN
===========================
CREATE TABLE test(c1 TEXT);

--test1() will be called not only by insert event.
Thus, it is here:
CREATE FUNCTION test1(test) RETURNS BOOL AS '
BEGIN
InRec ALIAS FOR $1;
RAISE NOTICE ''%'',InRec.c1;
RETURN TRUE;
END;' LANGUAGE 'plpgsql';

CREATE FUNCTION tftest() RETURNS OPAQUE AS '
BEGIN
PERFORM test1(NEW);
RETURN NEW;
END;' LANGUAGE 'plpgsql';

CREATE TRIGGER TriggerTest AFTER INSERT ON test FOR
EACH ROW EXECUTE PROCEDURE tftest();

--------------------------------------------------------
You too can have your own email address from Eurosport.
http://www.eurosport.com

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruce Momjian 2002-01-21 04:43:53 Re: [HACKERS] PostgreSQL Licence: GNU/GPL
Previous Message Bruce Momjian 2002-01-21 04:11:18 Re: Password type ?