[postgis-users] How to set parameters in 'options'?

Giuseppe Broccolo g.broccolo.7 at gmail.com
Wed Jan 30 03:07:18 PST 2019


Hi Stefan,

I didn't try, but I'd create dynamical SQL inside the function, i.e.
building the string with the statement needed to create the FDW server, and
then executing it with EXECUTE.

Hope it can help,
Giuseppe.

Il giorno mar 29 gen 2019 alle ore 14:37 Stefan Keller <sfkeller at gmail.com>
ha scritto:

> Sorry, not best list to ask that...
> :Stefan
>
> Am Di., 29. Jan. 2019 um 15:18 Uhr schrieb Stefan Keller <
> sfkeller at gmail.com>:
> >
> > Hi,
> >
> > I'd like to write a function like this:
> >
> > create function foo(_host text, _port text, _dbname text)
> > returns void as $$
> >   create server _server
> >     foreign data wrapper postgres_fdw
> >     options (host _host, port _port, dbname _dbname);
> >     -- ERROR: syntax error at or near "_host"
> > $$ language sql;
> >
> > In order to do:
> > select foo('111.11.11.11', '5432', 'mydb');
> >
> > How can I set the parameters in 'options' using those variables?
> >
> > :Stefan
> >
> > P.S. Actually I'll put this code in a plggsql later on.
> _______________________________________________
> postgis-users mailing list
> postgis-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/postgis-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20190130/e322ea06/attachment.html>


More information about the postgis-users mailing list