dblink inside plpgsql function

From: "Loredana Curugiu" <loredana(dot)curugiu(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org, pgsql-sql(at)postgresql(dot)org
Subject: dblink inside plpgsql function
Date: 2007-07-03 09:02:54
Message-ID: 1c23c8e70707030202n323ee171n20f39cdece5b3618@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice pgsql-sql

Hi everybody,

I created the following function:

CREATE OR REPLACE FUNCTION GetReminderServices( varchar ) RETURNS SETOF
reminder_services AS'
BEGIN
SELECT dblink_connect(''dbname=''||$1);
SELECT * FROM dblink(''SELECT * FROM reminder_services'')
AS reminder_services( uid INT,
theme_uid INT,
activity_MT_amount INT,
activity_min_days INT,
activity_max_months INT,
inactivity_days INT,
limit_reminders INT,
limit_months INT,
scanning_time TIMESTAMP WITH TIME ZONE,
reminder_time TIMESTAMP WITH TIME ZONE,
message TEXT);
SELECT dblink_disconnect($1);
RETURN;
END;
' LANGUAGE plpgsql;

When I call this function as SELECT * FROM GetReminderServices('eu');
I get the following errors:
ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function "getreminderservices" line 2 at SQL statement

Does somebody know which is the problem?

Best,
Loredana

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Pavel Stehule 2007-07-03 09:13:42 Re: dblink inside plpgsql function
Previous Message callewaert.nico 2007-07-03 06:48:43 Books on server programming

Browse pgsql-sql by date

  From Date Subject
Next Message Pavel Stehule 2007-07-03 09:13:42 Re: dblink inside plpgsql function
Previous Message Michael Glaesemann 2007-07-03 00:13:12 Re: Using escape strings in an insert statement.