| From: | Susan Cassidy <susan(dot)cassidy(at)decisionsciencescorp(dot)com> |
|---|---|
| To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
| Subject: | problem with trigger function |
| Date: | 2014-03-07 00:08:43 |
| Message-ID: | CAE3Q8on=r2hc+6pJ34C5mR_=JVgiiV5Z0_K1B23rLM7JnUdnFw@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
I'm having a problem with a trigger function. I've been googling for over
an hour, with no luck with my specific problem.
I get this error:
ERROR: missing FROM-clause entry for table "new"
LINE 1: insert into metric_double_values_201203 values (NEW.metricID...
^
QUERY: insert into metric_double_values_201203 values (NEW.metricID,
NEW.sourceID, NEW.timestamp, NEW.value, NEW.datetimeval)
CONTEXT: PL/pgSQL function metric_double_insert_func() line 8 at EXECUTE
statement
From this trigger function:
CREATE OR REPLACE FUNCTION metric_double_insert_func()
RETURNS TRIGGER AS $$
DECLARE insert_sql text;
BEGIN
insert_sql:='insert into metric_double_values_' ||
to_char(NEW.datetimeval,'YYYYMM') || ' values (NEW.metricID, NEW.sourceID,
NEW.timestamp, NEW.value, NEW.datetimeval)';
EXECUTE insert_sql using NEW;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
DROP TRIGGER insert_metric_double_insert_trigger on metric_double_values;
CREATE TRIGGER insert_metric_double_insert_trigger
BEFORE INSERT ON metric_double_values
FOR EACH ROW EXECUTE PROCEDURE metric_double_insert_func();
This was an attempt at eliminating the error I got when trying to insert
with values (NEW.*) using NEW:
ERROR: missing FROM-clause entry for table "new"
LINE 1: insert into metric_double_values_201203 values (NEW.*)
^
QUERY: insert into metric_double_values_201203 values (NEW.*)
CONTEXT: PL/pgSQL function metric_double_insert_func() line 7 at EXECUTE
statement
I don't know what from clause it is talking about
This is a trigger for inserting rows into the proper partition table based
on date.
Any help appreciated.
Thanks,
Susan
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Adrian Klaver | 2014-03-07 00:21:28 | Re: problem with trigger function |
| Previous Message | Rob Sargent | 2014-03-06 22:57:54 | Re: Offending My Tender Sensibilities -OR- OLTP on a Star Schema |