I want to connect (SELECT) from a local postgresql procedure to a remote server in order to store this table in localhost. I try using this:
CREATE SERVER foreign_server
FOREIGN DATA WRAPPER postgres_fdw
OPTIONS (host ip_server, port '15432', dbname 'omstar_analysis_' || project_id);
but a get this ERROR:
ERROR: syntax error at or near "||"
LINE 11: OPTIONS (host ''||ip_server, port '15432', dbname 'o...
Is obvious that the parameter only accept a string '127.0.0.1', as example, to make the connection but I want this procedure connects to multiple servers. So this is the reason I code the parameter as a variable ip_server
.
the declaration variable is below:
CREATE OR REPLACE FUNCTION get_cell_aggregation_cell_hour(ip_server VARCHAR, pass_server VARCHAR, project_id VARCHAR, cellkeys_list VARCHAR, itemid_list VARCHAR, busyhour_init INT, busyhour_finish INT, date_init VARCHAR, date_finish VARCHAR, aggre_obj VARCHAR, aggre_time VARCHAR)
RETURNS TABLE (DateLoaded varchar) AS $$
Is there another way to achieve multiple connections?
Im doing this because need to perform the procedures in every server as this procedure is not created in any server... Maybe there is a way to send and create the procedure in every server. Same issue for password parameter.
NOTE: All the server has the same data base structure, it only change id, passwords an IPs.
Thanks