I have another problem with a slightly different trigger. It's very weird, because it is exactly the same as the first trigger, that now works, except for the table name.
The error is:ERROR: query string argument of EXECUTE is null
CONTEXT: PL/pgSQL function metric_int_insert_func() line 5 at EXECUTE statement
CREATE OR REPLACE FUNCTION metric_int_insert_func()
RETURNS TRIGGER AS $$
DECLARE insert_sql text;
BEGIN
insert_sql:='insert into metric_int_values_' || to_char(NEW.datetimeval,'YYYYMM') || ' values ($1.*)';
EXECUTE insert_sql using NEW;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS insert_metric_int_insert_trigger on metric_int_values;
CREATE TRIGGER insert_metric_int_insert_trigger
BEFORE INSERT ON metric_int_values
FOR EACH ROW EXECUTE PROCEDURE metric_int_insert_func();
RETURNS TRIGGER AS $$
DECLARE insert_sql text;
BEGIN
insert_sql:='insert into metric_int_values_' || to_char(NEW.datetimeval,'YYYYMM') || ' values ($1.*)';
EXECUTE insert_sql using NEW;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS insert_metric_int_insert_trigger on metric_int_values;
CREATE TRIGGER insert_metric_int_insert_trigger
BEFORE INSERT ON metric_int_values
FOR EACH ROW EXECUTE PROCEDURE metric_int_insert_func();
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 ($1.*)';
EXECUTE insert_sql using NEW;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS 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();
I can't seem to figure it out. I've retyped some of the lines, in case there is a weird character somewhere, but they got there with a vi yank and put, so that's not likely.RETURNS TRIGGER AS $$
DECLARE insert_sql text;
BEGIN
insert_sql:='insert into metric_double_values_' || to_char(NEW.datetimeval,'YYYYMM') || ' values ($1.*)';
EXECUTE insert_sql using NEW;
RETURN NULL;
END;
$$
LANGUAGE plpgsql;
DROP TRIGGER IF EXISTS 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();
Anyone have any ideas?
Thanks,
Susan
Thanks,
Susan