
CREATE TABLE measurement (
    city_id         int not null,
    logdate         date not null,
    peaktemp        int,
    unitsales       int
);

CREATE TABLE measurement1 () inherits (measurement);


CREATE OR REPLACE FUNCTION measurement_insert_trigger()
RETURNS TRIGGER AS $$

BEGIN
        EXECUTE 'INSERT INTO measurement1 values(new.*)';
--        INSERT INTO measurement1 values(new.*);
	RETURN NULL;
END;
$$
LANGUAGE plpgsql;

CREATE TRIGGER insert_measurement_trigger
    BEFORE INSERT ON measurement
    FOR EACH ROW EXECUTE PROCEDURE measurement_insert_trigger();

insert into measurement values (1, '2013-1-2', 1, 1);

select * from measurement;

