Here is what I get from the documentation: The last two arguments are: text[] src_pk_att_vals_array, text[] tgt_pk_att_vals_array SELECT dblink_build_sql_insert('foo', '1 2', 2, '{"1", "a"}', '{"1", "b''a"}'); How do I replace the src and tgt with variables from within my function? I can easily create the insert statement with a true value, but if I loop over a record and try to dynamically set the src and tgt I get errors. declare bob_record record; frank character varying[]; for bob_record in select bob from table; loop frank = bob_record.bob; SELECT dblink_build_sql_insert('foo', '1',1, '{"frank"}', '{frank"}'); end loop; -- View this message in context: http://postgresql.1045698.n5.nabble.com/Using-Variables-in-dblink-build-sql-insert-tp5750332.html Sent from the PostgreSQL - general mailing list archive at Nabble.com. -- Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-general