Re: dblink inside plpgsql function - Mailing list pgsql-sql

From Loredana Curugiu
Subject Re: dblink inside plpgsql function
Date
Msg-id 1c23c8e70707030525m59ee79d0r425813cd93131bbc@mail.gmail.com
Whole thread Raw
In response to Re: dblink inside plpgsql function  ("Bart Degryse" <Bart.Degryse@indicator.be>)
Responses Re: dblink inside plpgsql function
List pgsql-sql
I created the following function<br /><br />CREATE OR REPLACE FUNCTION getReminderServices( varchar ) RETURNS SETOF
reminder_servicesAS'<br /> DECLARE r reminder_services%ROWTYPE;<br /> BEGIN<br />     SELECT
dblink_connect(''dbname=''||$1);<br/>     FOR r IN SELECT * FROM dblink(''SELECT * FROM reminder_services'')<br />
              AS columns( uid INT,<br />                                      theme_uid INT,<br />
                                    activity_MT_amount INT,<br />                                     
activity_min_daysINT,<br />                                      activity_max_months INT,<br />
                                    inactivity_days INT,<br />                                      limit_reminders
INT,<br/>                                      limit_months INT,<br />                                     
scanning_timeTIMESTAMP WITH TIME ZONE,<br />                                      reminder_time TIMESTAMP WITH TIME
ZONE,<br/>                                      message TEXT)<br />     LOOP<br />     RETURN NEXT r;<br />     END
LOOP;<br/>     SELECT dblink_disconnect($1);<br />     RETURN; <br /> END;<br /> ' LANGUAGE plpgsql; <br /><br /><br />
andI get the same errors. I think it is a problem with the dblink because<br /> the following function it works fine if
Icall SELECT * FROM getReminders().<br /><br /> CREATE OR REPLACE FUNCTION getReminders() RETURNS SETOF
reminder_servicesAS'<br /><br /> DECLARE r reminder_services%ROWTYPE;<br /><br /> BEGIN<br />     FOR r IN SELECT *
FROMreminder_services<br />     LOOP<br />     RETURN NEXT r;<br />     END LOOP;<br />     RETURN; <br /> END;<br /> '
LANGUAGEplpgsql; <br /><br /><br /><br /><br /><br /> 

pgsql-sql by date:

Previous
From: "Bart Degryse"
Date:
Subject: Re: dblink inside plpgsql function
Next
From: Richard Huxton
Date:
Subject: Re: dblink inside plpgsql function