View Full Version : PostGreSQL: Help - How to replace characters in dblink?

Jun 21st, 2007, 10:34 AM
Hi, I wanted to copy a data from table1 in db1 to table2 in db2, which has the same structure, with the PosgreSQL dblink funtion.

The fields for both the tables are: id, first_name, last_name.

However, I would like to replace the id and first_name in table1 to: 3 and 'nil' to insert into table2.

INSERT INTO table2 SELECT * FROM dblink('dbname=db1', 'SELECT 3, nil, last_name FROM table1 WHERE id = 1000') AS t1(id integer, first_name varchar, last_name varchar);

The id can be replaced but it thought "nil" is a column name, instead of the value that I wanted to replace the first_name with, thus return error.

Anyone knows how to replace characters in dblink or any solution to this problem??
Thanks in advance!

Jun 21st, 2007, 01:02 PM
enclose it in quotes.

Jun 22nd, 2007, 01:52 AM
I had tried that but PostGreSQL recognize it as a column