Am trying to run the following dblink start transaction;
select dblink_connect('host=remote port=5432 dbname=remote_db user=user password=pass');
insert into local_table (column1, column2 )
select * from dblink(`
select remote_column1 ltrim(remote_column2, ''TEST'') from remote_table
where remote_column2 ilike ''TEST%''
) as t(column1 varchar, column2 varchar) ;
now the above works fine, but am encountering a challenge:- I want instead of hardcoding TEST, I want it to be queried from a local table so I would wish to substitute TEST to something like SELECT uniq_id from some_local_table The logic behind it is I want to get records which has prefix matching the result of SELECT uniq_id from some_local_table but trim the prefix when inserting to local_table hope someone understands me