How to use dblink within pl/pgsql function:

From: Clive Page <cgp(at)star(dot)le(dot)ac(dot)uk>
To: pgsql-general(at)postgresql(dot)org
Subject: How to use dblink within pl/pgsql function:
Date: 2003-11-03 09:57:24
Message-ID: Pine.LNX.4.44L0.0311030956200.29653-100000@peneca.star.le.ac.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Paul Thomas 2003-11-03 10:07:42 Re: [Fwd: [LIH]OpenOffice.org 1.1 <-> PostgreSQL connectivity]
Previous Message Paul Thomas 2003-11-03 09:18:02 Re: PostgreSQL License Question