【发布时间】:2018-06-04 06:32:19
【问题描述】:
我已成功编译以下函数。当我执行select schema.funtion_name(); 时,该函数被执行,但表schema.table_insert 中没有插入任何行:
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
游标 cur_1 中的选择返回超过 900 000 条记录。当我对单个记录单独使用插入语句时,记录会插入到表中。
【问题讨论】:
标签: postgresql sql-insert plpgsql