以下の関数が正常にコンパイルされました。私はselect schema.funtion_name();
を行うと、関数が実行されますが、テーブルschema.table_insert
に挿入された行がないます:plpgsql関数が意図したとおりにデータを挿入していません
CREATE OR REPLACE FUNCTION schema.function_name()
RETURNS void AS
$BODY$
DECLARE cur_1 CURSOR FOR
Select col1 from schema.table1
union
select col1 from schema.table2
union
select col1 from schema.table3
union
select col1 from schema.table4;
BEGIN
FOR rec_i in cur_1 LOOP
insert into schema.table_insert (col1,col2,col3)
select col1,col2,col3
from schema.view
where col1=rec_i.col1
commit;
END LOOP;
END;
$BODY$
LANGUAGE plpgsql STABLE
900件の以上の000のレコードを返しますcur_1カーソルで選択します。 1つのレコードに対してinsertステートメントを個別に使用すると、そのレコードがテーブルに挿入されます。
[回答はありますか?](https://meta.stackexchange.com/questions/5234/how-does-accepting-an-answer-work) –