PL/pgSQL 関数を作成しようとしていますが、これは一時テーブルにデータを入力し、そこからすべての行を返す必要があります (後で結合されます) が、指定する戻り値の型がわかりません:
create or replace function pref_daily_misere() returns void as $BODY$
begin
create temporary table temp_best (id varchar not null) on commit drop;
insert into temp_best (id) select id from pref_money where
yw = to_char(current_timestamp - interval '1 week', 'IYYY-IW')
order by money desc limit 10;
select id from temp_best;
end;
$BODY$ language plpgsql;
上記のステートメントは単独で機能しますが、エラーが発生します
# select pref_daily_misere();
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 "pref_daily_misere" line 7 at SQL statement
私のPostgreSQL 8.4.11データベースでそれを呼び出そうとしたとき。
これはおそらく、上記の戻り値 voidの指定が間違っているためですが、代わりに使用する戻り値の型がわかりません。戻り値の型を省略するとコンパイル エラーになります。