0

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?

Community
  • 1
  • 1
Mayank
  • 5,454
  • 9
  • 37
  • 60
  • Just edit the question you originally posted, don't create a new one. – Ben Burns May 22 '11 at 09:00
  • @Ben: The accepted answer to the first question solves the problem of inserting **from** a remote table and has already received several upvotes. In my opinion the previous question needs to be edited *if only to reflect the accepted answer*. The OP's actual problem turned out different, and I agree with them about posting the actual question as a new one, rather than messing up things in the previous one. – Andriy M May 22 '11 at 09:24
  • @Andriy M: +1, This was exactly the reason I posted it as new :-) – Mayank May 22 '11 at 09:38
  • Ok, I added answer to previous question. – Grzegorz Szpetkowski May 22 '11 at 10:32

0 Answers0