Acessing columns of parent tables with PL/pgSQL - Mailing list pgsql-general

From Hans-Juergen Schoenig
Subject Acessing columns of parent tables with PL/pgSQL
Date
Msg-id 3D1B3F72.5000803@cybertec.at
Whole thread Raw
Responses Re: Acessing columns of parent tables with PL/pgSQL  (Manfred Koizar <mkoi-pg@aon.at>)
Re: Acessing columns of parent tables with PL/pgSQL  (Darko Prenosil <darko.prenosil@finteh.hr>)
List pgsql-general
I wonder if there is a way to access columns in a parent table when
running a PL/pgSQL trigger.

Here is an example:


CREATE TABLE a (
         one     text
);

CREATE TABLE b (
         two     text
) INHERITS (a);

CREATE FUNCTION myinsert() RETURNS opaque AS '
         BEGIN
                 RAISE NOTICE ''1 - NEW: %\n'', NEW.one;
                 RAISE NOTICE ''2 - NEW: %\n'', NEW.two;
                 RETURN NEW;
         END;
' LANGUAGE 'plpgsql';

CREATE TRIGGER mytrig BEFORE INSERT ON b
          FOR EACH ROW EXECUTE PROCEDURE myinsert();

INSERT INTO b VALUES ('a1', 'b2');


An error is displayed:


CREATE
CREATE
ERROR:  function myinsert already exists with same argument types
CREATE
NOTICE:  NEW: b2

INSERT 455182 1


As you can see the column of the parent table cannot be accessed. Is
there a way to get around the problem?

I guess this would be a damn good feature which could be important for
many developers.


    Hans


pgsql-general by date:

Previous
From: "sid@questions.com"
Date:
Subject: ecpg help
Next
From: "King King"
Date:
Subject: The Rule does not working.