Guest User

Untitled

a guest
Jul 27th, 2018
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. PostgreSQL dblink with named connections
  2. SELECT testtable.*
  3. FROM dblink('dbname=testdb port=5432 host=192.168.1.1 user=usr password=pw'
  4. ,'SELECT * FROM testtable')
  5. AS testtable(testtable_id integer, testtable_name text);
  6.  
  7. SELECT dblink_connect('myconn'
  8. ,'dbname=testdb port=5432 host=192.168.1.1 user=usr password=pw');
  9.  
  10. SELECT testtable.* FROM dblink('myconn', 'SELECT * FROM testtable')
  11. AS testtable(testtable_id integer, testtable_name text);
  12.  
  13. ERROR: could not establish connection
  14. DETAIL: missing "=" after "myconn" in connection info string
  15.  
  16. ********** Error **********
  17.  
  18. ERROR: could not establish connection
  19. SQL state: 08001
  20. Detail: missing "=" after "myconn" in connection info string
  21.  
  22. SELECT dblink_disconnect('myconn');
  23.  
  24. ERROR: connection "myconn" not available
  25.  
  26. ********** Error **********
  27.  
  28. ERROR: connection "myconn" not available
  29. SQL state: 08003
  30.  
  31. SELECT dblink_connect('dbname=testdb port=5432 host=192.168.1.1
  32. user=usr password=pw');
  33.  
  34. SELECT testtable.* FROM dblink('SELECT * FROM testtable')
  35. AS testtable(testtable_id integer, testtable_name text);
  36.  
  37. ERROR: connection not available
  38.  
  39. ********** Error **********
  40.  
  41. ERROR: connection not available
  42. SQL state: 08003
  43.  
  44. SELECT dblink_disconnect();
  45.  
  46. ERROR: connection not available
  47.  
  48. ********** Error **********
  49.  
  50. ERROR: connection not available
  51. SQL state: 08003
  52.  
  53. SELECT *
  54. FROM dblink('SELECT * FROM testtable'
  55. ) AS testtable (testtable_id integer, testtable_name text);
Add Comment
Please, Sign In to add comment