I have a table with schema names. I am writing a procedure to select schema name from the table and into a variable. The variable is then used to fetch records from the schema table. Sample code below.
CREATE OR REPLACE PROCEDURE vasmol_master.sp_pushmt(
)
LANGUAGE 'plpgsql'
AS $BODY$
DECLARE
shortcodedatabase CHARACTER VARYING;
services CHARACTER VARYING;
BEGIN
FOR shortcodedatabase IN SELECT dbase FROM vasmol_master.shortcode_services ORDER BY shortcode ASC LOOP
services := shortcodedatabase ||'.smsservices';
SELECT * FROM services;
END LOOP;
END
$BODY$;