I have this .sql script:
DO $$
DECLARE
user_list integer[] = (select user_id from user where state = 'ACTIVE');
BEGIN
CREATE CREATE MATERIALIZED VIEW accounts_with_active_users AS
select * from accounts where user_account IN (user_list);
...
CREATE CREATE MATERIALIZED VIEW accounts_without_active_users AS
select * from accounts where user_account NOT IN (user_list);
...
END $$;
However I always have this error:
ERROR: cannot cast type integer to integer[]
Also I have tried with the word array
before with the same result:
user_list integer[] = array(...)