pg 循环10000次进行插入

CREATE OR REPLACE FUNCTION tuomin()
RETURNS VOID
AS
$$
DECLARE
t_row RECORD;
BEGIN
FOR t_row in 1..10000 LOOP
  INSERT INTO "public"."log_task_execution"("station_id", "hall_id", "detector_id", "task_template_id", "task_id", "station_name", "hall_name", "task_name",   "task_template_name", "detector_name", "detector_code", "task_type", "task_mode", "expected_execution_time_start", "actual_execution_time_start",   "expected_execution_time_end", "actual_execution_time_end", "execution_result", "create_date", "update_date", "create_by", "update_by", "remarks") VALUES (2, 2, 4,       2, 2, '驻地1', '会场1', '任务1', '模板1', '探针3', 'b486c54c', 1, 1, '2021-09-06 16:19:57.993', '2021-09-06 16:19:57.993', '2021-09-06 16:19:57.993', '2021-09-06 16:19:57.993', 1, '2021-09-06 17:57:15.26', '2021-09-06 17:57:15.26', NULL, NULL, NULL);

END LOOP;
END;
$$
LANGUAGE plpgsql;

SELECT tuomin() as output;

posted @ 2021-09-07 20:49  wangssd  阅读(529)  评论(0编辑  收藏  举报