@@ -82,7 +82,8 @@ Outputs
8282
8383Example usage
8484
85- select dblink('hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd','select f1, f2 from mytable');
85+ select dblink('hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
86+ ,'select f1, f2 from mytable');
8687
8788
8889==================================================================
@@ -118,44 +119,16 @@ Example usage
118119
119120==================================================================
120121
121- NOTE: If you need to provide selection criteria in a WHERE clause, it is necessary
122- to 'fake' a UNION, e.g.
123-
124- select
125- dblink_tok(t1.dblink_p,0) as f1
126- ,dblink_tok(t1.dblink_p,1) as f2
127- from
128- (
129- select dblink(
130- 'hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
131- ,'select f1, f2 from mytable'
132- ) as dblink_p
133- union all
134- select null where false
135- ) as t1
136- where
137- dblink_tok(t1.dblink_p,0) = 'mycriteria';
138-
139- in order to work around an issue with the query optimizer. A more convenient way to approach
140- this problem is to create a view:
141-
142- create view myremotetable as
143- select
144- dblink_tok(t1.dblink_p,0) as f1
145- ,dblink_tok(t1.dblink_p,1) as f2
146- from
147- (
148- select dblink(
149- 'hostaddr=127.0.0.1 port=5432 dbname=mydb user=postgres password=mypasswd'
150- ,'select f1, f2 from mytable'
151- ) as dblink_p
152- union all
153- select null where false
154- ) as t1;
122+ A more convenient way to use dblink may be to create a view:
123+
124+ create view myremotetable as
125+ select dblink_tok(t1.dblink_p,0) as f1, dblink_tok(t1.dblink_p,1) as f2
126+ from (select dblink('hostaddr=127.0.0.1 port=5432 dbname=template1 user=postgres password=postgres'
127+ ,'select proname, prosrc from pg_proc') as dblink_p) as t1;
155128
156129Then you can simply write:
157130
158- select f1,f2 from myremotetable where f1= 'mycriteria ';
131+ select f1, f2 from myremotetable where f1like 'bytea% ';
159132
160133==================================================================
161134