How to use dblink within pl/pgsql function: - Mailing list pgsql-general

From Clive Page
Subject How to use dblink within pl/pgsql function:
Date
Msg-id Pine.LNX.4.44L0.0311030956200.29653-100000@peneca.star.le.ac.uk
Whole thread Raw
Responses Re: How to use dblink within pl/pgsql function:  (Joe Conway <mail@joeconway.com>)
List pgsql-general
What I'd like to do is use dblink to extract a few rows from a remote
database and manipulate these within a function in pl/pgsql.  Something
like this:

CREATE OR REPLACE FUNCTION find() RETURNS INTEGER AS '
  DECLARE
    count INTEGER:
    myrec RECORD;
  BEGIN
  FOR myrec IN SELECT * FROM DBLINK(''select x,y from mytab'') as
     temp(x integer, y real) LOOP
     count := count + 1;
  END LOOP;
  RETURN count;
END; ' LANGUAGE 'plpgsql';


But this syntax does not work, and I cannot find a form which does work.
Does anyone know how to do this?

Thanks in advance.

--
Clive Page


pgsql-general by date:

Previous
From: "Russell Crosser"
Date:
Subject: Internet based database
Next
From: Stephan Szabo
Date:
Subject: Re: slow down on UPDATE using IN statements