Possible Duplicate:
postgresql: INSERT INTO … (SELECT * …)
Referring to postgresql: INSERT INTO ... (SELECT * ...)
I think either I could not explain my question or I did not understand the solution. So restating here.
INSERT INTO tblA
(SELECT id, time
FROM tblB
WHERE time > 1000)
What I'm looking for is: what if tblA is in remote DB Server
Now the SELECT TABLE ie tblB
is in current session. I need top 20 rows based on some criteria and INSERT INTO remote (viz tblA) table using dblink
CREATE VIEW v AS SELECT TOP 20 id, time FROM tblB;
SELECT db_link('dbname=remote_db', 'INSERT INTO tblB SELECT id, time FROM v')
But 'INSERT INTO tblB SELECT id, time FROM v'
view v here will be interpreted as created in remote DB I believe.
Is it possible to SELECT FROM
current session and INSERT INTO
remote session in postgresql?