"Woody Woodring" <george.woodring@iglass.net> writes:
> My trigger is :
> CREATE OR REPLACE FUNCTION log_cpe_health() RETURNS trigger AS '
> DECLARE
> BEGIN
> -- Update last outage before inserting
> EXECUTE ''INSERT INTO cpe_health_history VALUES '' || NEW;
> END;
> ' LANGUAGE plpgsql;
That's never going to work because of quoting issues, and it wouldn't be
an efficient way if it did work (because of having to re-parse and
re-plan the INSERT each time). And if it did act the way you are
imagining, it still wouldn't be a good way because you typically want
some additional columns in the log table, such as a timestamp.
In recent releases you can do it like this:
INSERT INTO cpe_health_history VALUES (NEW.*);
which can be extended to, eg,
INSERT INTO cpe_health_history VALUES (NEW.*, now());
regards, tom lane