From: | Darko Prenosil <darko(dot)prenosil(at)finteh(dot)hr> |
---|---|
To: | pgsql-hackers(at)postgresql(dot)org |
Subject: | Rules |
Date: | 2004-06-09 11:50:25 |
Message-ID: | 200406091350.25519.darko.prenosil@finteh.hr |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Why is this wrong ?:
DROP SCHEMA test CASCADE ;
CREATE SCHEMA test;
CREATE TABLE test.parent (
id serial PRIMARY KEY,
opis text
);
CREATE TABLE test.child_data (
id serial PRIMARY KEY,
id_parent int ,
podaci text,
FOREIGN KEY (id_parent) REFERENCES test.parent(id)
);
CREATE VIEW test.child AS
SELECT p.id AS id,
p.opis AS opis,
c.id AS id_data,
c.id_parent AS id_parent,
c.podaci AS podaci
FROM
test.parent p, test.child_data c
WHERE c.id_parent = p.id;
CREATE FUNCTION test.testfi(test.child) RETURNS bool AS '
DECLARE
_NEW ALIAS FOR \$1;
BEGIN
RAISE NOTICE ''%'',_NEW.opis;
INSERT INTO test.parent (id,opis) VALUES (_NEW.id,_NEW.opis);
INSERT INTO test.child_data (id,id_parent,podaci) VALUES
(_NEW.id_data,_NEW.id,_NEW.podaci);
RETURN TRUE;
END; '
LANGUAGE 'plpgsql';
CREATE RULE child_ins AS ON INSERT TO test.child
DO INSTEAD SELECT test.testfi(NEW);
INSERT INTO test.child(id,id_data,opis,podaci) VALUES (1,1,'Opis','podaci');
Gives:
(-403)ERROR: cannot handle whole-row reference
Can I pass NEW & OLD from rule into function in any way ?
Any suggestions ?
Regards !
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew Dunstan | 2004-06-09 11:56:13 | Re: Question regarding dynamic_library_path |
Previous Message | Thomas Hallgren | 2004-06-09 11:04:20 | Re: Question regarding dynamic_library_path |