나는 ... 등등이plpgsql에서 루프의 결과를 반환하는 방법은 무엇입니까?
"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"
같은 를 날짜를 표시하는 결과를보고 싶어하지만, 스피지고 오류가
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
당신은 문제를
기능이 무엇인지 말해 줄 수 내가 만든
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<=end_date
loop
select start_date;
start_date:=start_date+ interval '1 day';
End loop;
return start_date;
end;
$$
LANGUAGE 'plpgsql';
이 기능에 문제가 뭔지는 내가 선택 statment..please의 모든 열이 나에게 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 <= 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;
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 **********
함수와 루프가 필요 없습니다. 'generate_series ('2001-01-01 00:00:00', '2010-01-01 00:00:00', '1day :: interval)'을 사용하여 시계열을 생성 할 수 있습니다. – wildplasser
오류 메시지는 명확합니다 :'select' 결과는 어딘가에 저장되어야합니다 : https://www.postgresql.org/docs/current/static/plpgsql-statements.html#PLPGSQL-STATEMENTS-SQL-ONEROW –