Skip site navigation (1) Skip section navigation (2)

Re: [SQL] dblink inside plpgsql function

From: "Loredana Curugiu" <loredana(dot)curugiu(at)gmail(dot)com>
To: "Richard Huxton" <dev(at)archonet(dot)com>, pgsql-sql(at)postgresql(dot)org, pgsql-novice(at)postgresql(dot)org
Subject: Re: [SQL] dblink inside plpgsql function
Date: 2007-07-03 12:50:18
Message-ID: 1c23c8e70707030550j69f1911dj6cf33ab0a7db4776@mail.gmail.com (view raw or flat)
Thread:
Lists: pgsql-novicepgsql-sql
CREATE OR REPLACE FUNCTION getReminderServices( varchar ) RETURNS SETOF
reminder_services AS'

DECLARE r reminder_services%ROWTYPE;

BEGIN
    PERFORM dblink_connect(''dbname=''||$1);
    FOR r IN SELECT * FROM dblink(''SELECT * FROM reminder_services'')
               AS columns( 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)
    LOOP
    RETURN NEXT r;
    END LOOP;
    PERFORM dblink_disconnect($1);
    RETURN;
END;
' LANGUAGE plpgsql;

Now I get the errors:

connection "eu" not available
CONTEXT:  SQL statement "SELECT  dblink_disconnect( $1 )"
PL/pgSQL function "getreminderservices" line 21 at perform

In response to

Responses

pgsql-novice by date

Next:From: Richard HuxtonDate: 2007-07-03 12:58:26
Subject: Re: dblink inside plpgsql function
Previous:From: Richard HuxtonDate: 2007-07-03 12:32:13
Subject: Re: dblink inside plpgsql function

pgsql-sql by date

Next:From: Richard HuxtonDate: 2007-07-03 12:58:26
Subject: Re: dblink inside plpgsql function
Previous:From: Richard HuxtonDate: 2007-07-03 12:32:13
Subject: Re: dblink inside plpgsql function

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group