I'm pretty new with pgAdmin and I was tasked to create a dynamic function where it loops through an existing function and updates a dynamic table per day. This dynamic function will have a date parameter and a function parameter (for the existing function that we would need to loop through).
I can't quite understand nor imagine what this will be and how it will look like. I have been told that this function should act like how a materialized view's update script should act.
So far, this is my pseudo code on how the query for this dynamic function should look like:
DECLARE
ids RECORD;
BEGIN
DELETE FROM agg_table_per_function WHERE created_at_utc_date = queried_date;
FOR ids IN
(function_name, date)
LOOP
INSERT INTO agg_table_per_function (created_at_utc_date, json_text)
SELECT (json_populate_record(NULL::agg_table_per_function, json_text::json)).*;
END LOOP;
RETURN TRUE;
END
Is there a better way to understand this? I'm not quite sure where to start and I'm also unsure how to go about to looking for the solution to this.