Hi i am trying to create a function which loops from 1 to 12 and then use that loop value to calculate a date here is my code so far for the loop which is where the problem is.
FOR i IN 1..12 LOOP
r.duedate := alert_start_period + interval 'i month';
RAISE NOTICE 'Month % gives date of %', i, r.duedate;
END LOOP;
I know the problem is how i am referencing the value i. How do i correctly reference i from the loop so the interval is correct please.
The Error being thrown is
ERROR: invalid input syntax for type interval: "i month"