I'm trying to pass a variable to a select statement using PostgreSQL. The overall goal is to use this logic in a stored procedure where the variable deadline_interval would be an input parameter. Here's what I've tried so far:
DO
$$
DECLARE
date_deadline date;
deadline_interval varchar := '6 month';
BEGIN
date_deadline := (SELECT CURRENT_DATE - INTERVAL deadline_interval);
RAISE NOTICE 'here: %', date_deadline;
END;
$$
Unfortunately the variable deadline_interval is undefined in the select statement. What am I doing wrong here?