I want to write a code that interates from TIMESTAMP_START to TIMESTAMP_END with an variable INTERVAL. My hardcoded working code looks like this:
LOOP
...DO SMTH...
TIMESTAMP_START := (TIMESTAMP_START + INTERVAL '30' MINUTE);
EXIT WHEN TIMESTAMP_START > TIMESTAMP_END;
END LOOP;
When I try to replace the type of the interval I get a Syntax Error:
DECLARE INCREMENT_TYPE INTERVAL := minute;
...
TIMESTAMP_START := (TIMESTAMP_START + INTERVAL '30' INCREMENT_TYPE);
The same happens whe I try to variable the step:
DECLARE STEP text := '30';
...
TIMESTAMP_START := (TIMESTAMP_START + INTERVAL STEP MINUTE);
I assuming I am doing something wrong, but googling the documentations does not gave me the answer. What is the correct procedure to this problem?