Closed oscardssmith closed 8 years ago
There is some code in the multicorn_alchemy_test file that does something like this. Maybe take a look there. (excerpt pasted below).
create or replace function create_foreign_server() returns void as $block$
DECLARE
current_db varchar;
BEGIN
SELECT into current_db current_database();
EXECUTE $$
CREATE server multicorn_srv foreign data wrapper multicorn options (
wrapper 'multicorn.sqlalchemyfdw.SqlAlchemyFdw',
db_url 'postgresql://$$ || current_user || '@localhost/' || current_db || $$'
);
$$;
END;
$block$ language plpgsql;
select create_foreign_server();
I am trying to pass my fdw an option who's value is a variable. My instinct is to do it like this, but it says that there is a syntax error at
x abc
. What do I need to do to get this to work? `DO $$ DECLARE abc varchar :='hi'; Begin drop server partner cascade; create server partner foreign data wrapper multicorn options( wrapper 'multicorn.fdw.Fdw' );END $$;`