Is there a way to create a table variable in postgresql -
i have created function creates temporary table , inserts table. problem need work in read-only instance , in read-only instance can't create table and/or insert it. there other way of doing this? maybe creating table variable in way similar other sql languages?
i did research , there doesn't seem table variable, maybe array of records? ideas?
update: answer people's questions, trying create function returns list of dates until x intervals ago in intervals of y. instance select * getdates('3 days', 1 day') returns:
startdate  |  enddate    ------------+------------  2016-07-20 | 2016-07-21  2016-07-19 | 2016-07-20  2016-07-18 | 2016-07-19   and select * getdates('3 months', '1 month'); returns:
startdate  |  enddate    ------------+------------  2016-07-01 | 2016-08-01  2016-06-01 | 2016-07-01  2016-05-01 | 2016-06-01   i using while loop , going per interval until hit time given first parameter. insert values temp table , when finished select table. can include code if necessary.
declare function retuning table
create function f() returns table (     int,     b text ) $$     select x, y t; $$ language sql;   use as:
select * f()      
Comments
Post a Comment