Answer the question
In order to leave comments, you need to log in
How to return a temporary table from a hypertable?
There is a hypertable:
CREATE TABLE IF NOT EXISTS hyptab(
key integer NOT NULL,
tstamp timestamptz NOT NULL,
val FLOAT NOT NULL);
SELECT create_hypertable(
'hyptab', 'tstamp',
chunk_time_interval => INTERVAL '1 day',
if_not_exists => TRUE
);
INSERT INTO hyptab (key, tstamp, val)
SELECT n, NOW(), n FROM (
SELECT generate_series(1, 100500) AS n
) AS newvalues
CREATE OR REPLACE FUNCTION Foo(st TIMESTAMP, fin TIMESTAMP)
RETURNS ... AS $$
DECLARE
--
BEGIN
--
END;
$$ LANGUAGE plpgsql;
Answer the question
In order to leave comments, you need to log in
Yes, as usual, I don’t think that something is different in TimescaleDB:
CREATE OR REPLACE FUNCTION Foo(st TIMESTAMP, fin TIMESTAMP)
RETURNS TABLE (tstamp timestamptz, val float) AS $$
...
RETURN QUERY SELECT tstamp, val FROM hyptab WHERE tstamp >= st AND tstamp < fin;
END;
$$ LANGUAGE plpgsql;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question