Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
On Wed, Sep 17, 2008 at 5:45 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Wed, Sep 17, 2008 at 05:08:39PM +0200, Raphael Bauduin wrote: >> Would you have a little example on how you would do it? > > show us what you have done - it will be easier to find/fix/explain than > to write

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2008-09-17 Thread Raphael Bauduin
HI, On Sat, Aug 11, 2007 at 9:07 PM, hubert depesz lubaczewski <[EMAIL PROTECTED]> wrote: > On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote: >> I think that it's working alright except for the next line: > > doing this in plpgsql is very complicated (or even impossible assuming >

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread hubert depesz lubaczewski
On Sat, Aug 11, 2007 at 02:45:09AM -0500, Javier Fonseca V. wrote: > I think that it's working alright except for the next line: doing this in plpgsql is very complicated (or even impossible assuming that any table can have the same trigger). i would rather suggest using pl/perl - writing somethin

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Javier Fonseca V.
Yes Tom, you're right, but the real problem is that I need to use an EXECUTE statement because my table name is dynamic. In your example, you used logt as a static table name, and that doesn't need an EXECUTE statement. So I think that I'll have to rewrite a Trigger Procedure for each table and t

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Pavel Stehule
2007/8/11, Tom Lane <[EMAIL PROTECTED]>: > "Pavel Stehule" <[EMAIL PROTECTED]> writes: > > NEW is only plpgsql variable. It isn't visible on SQL level. > > Correct, but: > > > You cannot use new.*, you can: > > execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b > > You're both overthin

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Tom Lane
"Pavel Stehule" <[EMAIL PROTECTED]> writes: > NEW is only plpgsql variable. It isn't visible on SQL level. Correct, but: > You cannot use new.*, you can: > execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b You're both overthinking the problem. In recent releases (at least since 8.

Re: [SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Pavel Stehule
NEW is only plpgsql variable. It isn't visible on SQL level. You cannot use new.*, you can: execute 'INSERT ...' || 'VALUES(' || new.a || ',' || new.b regards Pavel 2007/8/11, Javier Fonseca V. <[EMAIL PROTECTED]>: > > > Hello. > > I'm doing a Trigger Procedure in pl/pgSQL. It makes some k

[SQL] Trigger Procedure Error: NEW used in query that is not in a rule

2007-08-11 Thread Javier Fonseca V.
Hello. I'm doing a Trigger Procedure in pl/pgSQL. It makes some kind of auditing. I think that it's working alright except for the next line: EXECUTE 'INSERT INTO ' || quote_ident(somedynamictablename) || ' SELECT new.*'; PostgreSQL keeps telling me: "ERROR: NEW used in query that is not in a