Search Postgresql Archives

Re: Postgres Triggers issue

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> -----Original Message-----
> From: u235sentinel [mailto:u235sentinel@xxxxxxxxx] 
> Sent: Wednesday, February 10, 2010 11:15 PM
> To: pgsql-general@xxxxxxxxxxxxxx
> Subject: Postgres Triggers issue
> 
> I have a strange problem we noticed the other day with 
> triggers.  We're running 8.3.3 on Solaris 10 (intel) and have 
> a feed that comes in regularly to populate a table we're 
> working on.  The feed works just fine inserting rows however 
> the following trigger stops the feed until we remove the 
> trigger.  Any thoughts on what I'm doing wrong here?
> 
> Thanks!
> 
> ---
> 
> CREATE OR REPLACE FUNCTION r.m_t()
> RETURNS trigger AS
> $BODY$
> BEGIN
>  INSERT INTO temp_m_t VALUES (NEW.*,1+1); RETURN NULL; END; 
> $BODY$ LANGUAGE 'plpgsql';
> 
> 
> CREATE TRIGGER tafter
> AFTER INSERT OR UPDATE
> ON r.m_a
> FOR EACH ROW
> EXECUTE PROCEDURE r.m_t();
> 
> 

Trigger function for an insert/update trigger should return "NEW", not
NULL (OLD - for "on delete" trigger):

 CREATE OR REPLACE FUNCTION r.m_t()
 RETURNS trigger AS
 $BODY$
 BEGIN
  INSERT INTO temp_m_t VALUES (NEW.*,1+1); RETURN NEW; END; 
 $BODY$ LANGUAGE 'plpgsql';
 

Igor Neyman

-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux