How to return results from a loop in plpgsql?
<p>I want to see the result displaying dates like this</p>

<pre><code> "2001-01-01 00:00:00+05:30"
 "2001-01-02 00:00:00+05:30"
 "2001-01-03 00:00:00+05:30"
 "2001-01-04 00:00:00+05:30"
 "2001-01-05 00:00:00+05:30"
 "2001-01-06 00:00:00+05:30"
 "2001-01-07 00:00:00+05:30"
</code></pre>

<p>so on...
but iam getting error</p>

<pre><code>ERROR:  query has no destination for result data
HINT:  If you want to discard the results of a SELECT, use PERFORM      instead.
CONTEXT:  PL/pgSQL function insert_date_dimension(date) line 12 at SQL statement
</code></pre>

<p>can  you tell me what is the issue</p>

<p>function i created</p>

<pre><code>create or replace function insert_date_dimension("Date" date)
returns text as
$$
Declare dat date;
start_date date;
end_date date;
Begin
start_date:='2016/01/01';
end_date:='2016/12/31';
while start_date&lt;=end_date 
loop
select start_date;
start_date:=start_date+ interval  '1 day';
End loop;
return start_date;
end;
$$
LANGUAGE 'plpgsql';
</code></pre>

<p>can you tell me what is the issue with this function i was not able to execute it.I want to take all the column in select statment..please tell me                                                                                            <code>create or replace function insert_date_dimension("date" date)
returns setof date as $$
    declare
        dat date;
        start_date date;
        end_date date;
    begin
        start_date := '2016/01/01';
        end_date := '2016/12/31';
        while start_date &lt;= end_date loop
            --return next  start_date;
            select start_date,date_part('week',start_date),date_part('quarter',start_date),to_char(start_date, 'day'),to_char(start_date, 'month'),
            extract(year from current_date),extract(month from current_date);
            start_date:= start_date + interval  '1 day';
        end loop;
    end;
$$ language plpgsql;</code></p>

<pre><code>  ERROR:  query has no destination for result data
  HINT:  If you want to discard the results of a SELECT, use PERFORM    instead.
  CONTEXT:  PL/pgSQL function insert_date_dimension(date) line 11 at SQL    statement
  ********** Error **********
</code></pre>