<div dir="ltr"><div>Hi Stefan,</div><div><br></div><div>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.</div><div><br></div><div>Hope it can help,</div><div>Giuseppe.<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Il giorno mar 29 gen 2019 alle ore 14:37 Stefan Keller <<a href="mailto:sfkeller@gmail.com">sfkeller@gmail.com</a>> ha scritto:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Sorry, not best list to ask that...<br>
:Stefan<br>
<br>
Am Di., 29. Jan. 2019 um 15:18 Uhr schrieb Stefan Keller <<a href="mailto:sfkeller@gmail.com" target="_blank">sfkeller@gmail.com</a>>:<br>
><br>
> Hi,<br>
><br>
> I'd like to write a function like this:<br>
><br>
> create function foo(_host text, _port text, _dbname text)<br>
> returns void as $$<br>
>   create server _server<br>
>     foreign data wrapper postgres_fdw<br>
>     options (host _host, port _port, dbname _dbname);<br>
>     -- ERROR: syntax error at or near "_host"<br>
> $$ language sql;<br>
><br>
> In order to do:<br>
> select foo('111.11.11.11', '5432', 'mydb');<br>
><br>
> How can I set the parameters in 'options' using those variables?<br>
><br>
> :Stefan<br>
><br>
> P.S. Actually I'll put this code in a plggsql later on.<br>
_______________________________________________<br>
postgis-users mailing list<br>
<a href="mailto:postgis-users@lists.osgeo.org" target="_blank">postgis-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/postgis-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/postgis-users</a></blockquote></div>