functions for triggers: passing parameters

From: Nico <nicod(at)tiscalinet(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: functions for triggers: passing parameters
Date: 2001-03-09 17:35:25
Message-ID: 01030918352504.03022@localhost.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

What is wrong?

CREATE FUNCTION set_value(text) RETURNS OPAQUE AS '
DECLARE
val ALIAS FOR $1;
BEGIN
NEW.inf := val;
RETURN NEW;
END;
' LANGUAGE 'plpgsql';

CREATE TABLE t1 (
id serial,
info text
);
CREATE TRIGGER t1_set_val BEFORE INSERT ON t1
FOR EACH ROW EXECUTE PROCEDURE set_value('some info');

============================
psql 7.1beta5 result:

CREATE
psql:function_for_trigger.sql:15: NOTICE: CREATE TABLE will create implicit
sequence 't1_id_seq' for SERIAL column 't1.id'
psql:function_for_trigger.sql:15: NOTICE: CREATE TABLE/UNIQUE will create
implicit index 't1_id_key' for table 't1'
CREATE
psql:function_for_trigger.sql:17: ERROR: CreateTrigger: function set_value()
does not exist
test=#

(the language plpgsql is already loaded)

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Frank Joerdens 2001-03-09 17:53:52 Re: Forein Key
Previous Message Brent R. Matzelle 2001-03-09 17:26:50 Re: Re: pgsql for Python