I have a SQL script like so:
SELECT 'drop table if exists '||schemaname||'.'|| tablename || ' cascade;'
FROM pg_tables
WHERE schemaname in ('schema_1','schema_2','schema_2');
I want to create a stored procedure to execute all the commands this script generates. If you run the script now it gives an output like so:
drop table if exists schema_1.table_a cascade;
drop table if exists schema_2.table_b cascade;
drop table if exists schema_3.table_c cascade;
drop table if exists schema_1.table_d cascade;
I know you can have loops execute multiple lines one after another but I'm having trouble following the redshift docs to get this work. Any help would be appreciated!