dblink_open

Name

dblink_open -- opens a cursor on a remote database

Synopsis

 dblink_open(text cursorname, text sql [, bool fail_on_error])
 dblink_open(text connname, text cursorname, text sql [, bool fail_on_error])
   

Inputs

connname

if three arguments are present, the first is taken as the specific connection name to use; otherwise the unnamed connection is assumed

cursorname

a reference name for the cursor

sql

sql statement that you wish to execute on the remote host e.g. "select * from pg_class"

fail_on_error

If true (default when not present) then an ERROR thrown on the remote side of the connection causes an ERROR to also be thrown locally. If false, the remote ERROR is locally treated as a NOTICE, and the return value is set to 'ERROR'.

Outputs

Returns status = "OK"

Note

Example

 test=# select dblink_connect('dbname=postgres');
  dblink_connect
 ----------------
  OK
 (1 row)
 
 test=# select dblink_open('foo','select proname, prosrc from pg_proc');
  dblink_open
 -------------
  OK
 (1 row)