Skip site navigation (1) Skip section navigation (2)

Error in trigger

From: "Negandhi, Nishith" <Nishith(dot)Negandhi(at)infoUSA(dot)com>
To: <pgsql-admin(at)postgresql(dot)org>
Subject: Error in trigger
Date: 2007-01-19 01:18:05
Message-ID: FE0C41EEBEF01C47BF3A91F60669446804973253@PUNISHER.intra.infousa.com (view raw or flat)
Thread:
Lists: pgsql-admin
Hi,
All my tables in the database have "CreateDate" and "LastUpdateDate"
columns. I need to create a trigger wherein on insert the "CreateDate"
column is inserted with the current date. On Update the "LastUpdateDate"
is inserted with the current date.
 
I tried the insert trigger as mentioned below:
 
CREATE FUNCTION "CreateDate_F"() RETURNS TRIGGER AS $CreateDate_T$
BEGIN
insert into "CreateDate" values (CURRENT_TIMESTAMP);
END; 
$CreateDate_T$ LANGUAGE plpgsql;
 
CREATE TRIGGER "Create_Date_T" AFTER INSERT ON "CreateDate"
FOR EACH STATEMENT EXECUTE PROCEDURE "CreateDate_F"();
 
However, when I run the insert on the said table, I get the following
error:
 
ERROR:  stack depth limit exceeded
HINT:  Increase the configuration parameter "max_stack_depth".
CONTEXT:  SQL statement "insert into "CreateDate" values
(CURRENT_TIMESTAMP)"
PL/pgSQL function "CreateDate_F" line 2 at SQL statement
 
Other than the above, is there any other way of doing this.???
Any suggestions please .???
 
Regards

Responses

pgsql-admin by date

Next:From: David F. SkollDate: 2007-01-19 01:37:33
Subject: Strange performance hit upgrading from 8.0.9 to 8.2.1
Previous:From: Chad WagnerDate: 2007-01-19 00:10:55
Subject: Re: System Date

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group