CREATE OR REPLACE FUNCTION "public"."totalrecord_sub"() -- totalrecord_sub为函数名称
RETURNS "pg_catalog"."int4" AS $BODY$
declare
total integer;
BEGIN
total=0;
WHILE total <= 1000 loop
INSERT INTO "public"."event_subscribe_log"("id", "subscriber_id", "event_id", "subscribe_type", "push_content", "create_time", "update_time", "is_deleted", "retry_times", "push_to_subscriber_status", "retry_count") VALUES (total, '1480476510137716738', 1447523098156453889, '1', '{"timestamp":1641804364856,"payloadId":"1480460925190377474","tenantId":"60fa59a28afc2e004abf61c5","eventId":1447523098156453889,"publishTimestamp":1641804364856,"payload":"{\"__properties__\":{\"__online__\":{\"connected\":false,\"directlyLinked\":true}},\"cts\":1641804364840,\"deviceId\":\"14wC755IgrC\",\"deviceTypeId\":\"13KToMDfvt6\"}","action":"all_online_event","compressed":null}', '2021-01-30 11:36:24', '2021-01-24 16:05:50.979', '0', 0, '0', 0); -- sql插入语句
total=total+1;
END loop;
RETURN total;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100