Re: [GENERAL] column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!

2009-06-09 Thread Stephan Szabo
On Tue, 9 Jun 2009, G. Allegri wrote: > Hello list. > I'm a newbie with plpgsql, so I'm sorry for doing stupid questions... > I have a situation whit one table where items are related to two other > tables through a common id (unique in the first table) and the table > name. Whenever the user exec

Re: [GENERAL] column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!

2009-06-09 Thread G. Allegri
Stephan, you're rigth. It was just a first try. In the real situation "seconda" and "terza" have a prima_id column. So the right one is: execute 'UPDATE '|| NEW.tabella ||' SET nome='|| quote_literal(NEW.nome) ||' WEHERE prima_id=' || NEW.id || ';'; I though that double apices would quote. That w

Re: [GENERAL] column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!

2009-06-09 Thread G. Allegri
Great, quote_literal() solved it! It was so easy :) Thx Richard 2009/6/9 Richard Huxton : > G. Allegri wrote: >> >> ERROR: Column 'lets_try' does not exist >> LINE 1: INSERT INTO seconda (nome) VALUES ('lets_try') >> >> My function and trigger are: >> >> CREATE OR REPLACE FUNCTION fun1() RETURNS

Re: [GENERAL] column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!

2009-06-09 Thread Richard Huxton
G. Allegri wrote: ERROR: Column 'lets_try' does not exist LINE 1: INSERT INTO seconda (nome) VALUES ('lets_try') My function and trigger are: CREATE OR REPLACE FUNCTION fun1() RETURNS TRIGGER AS $primaprova$ DECLARE nome varchar; BEGIN IF (TG_OP='INSERT') THEN execute 'INSERT INTO ' || NEW.tab

[GENERAL] column name gets substitudes inside an execute statement of a trigger function. how to avoid it?!

2009-06-09 Thread G. Allegri
Hello list. I'm a newbie with plpgsql, so I'm sorry for doing stupid questions... I have a situation whit one table where items are related to two other tables through a common id (unique in the first table) and the table name. Whenever the user execute an operation on an item of the first one ("pr