I'd like to create an SQL file, where the user can just change variables on the beginning , and use it in different configuration system. Typically for load layer from different PostGIS server with postgres_fdw.
I tried it with PL/pgSQL where I can declare variables before beginning processing, but I don't no how to use them after...
DO $$ DECLARE url character := '193.00.00.00'; pt character := '5432'; db character := 'bd_name'; usr character := 'user_name'; pwd character := 'password'; BEGIN CREATE EXTENSION IF NOT EXISTS postgres_fdw; CREATE SERVER foreign_srv FOREIGN DATA WRAPPER postgres_fdw OPTIONS (host url, port pt, dbname db); CREATE USER MAPPING FOR USER SERVER foreign_srv OPTIONS (user usr, password pwd); END $$;
It obviously doesn't work like that.