Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Loredana Curugiu
I should read the documentation carrefully .. Yes, you're right, Richard. Many thanks to all. Best, Loredana

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Richard Huxton
Loredana Curugiu wrote: CREATE OR REPLACE FUNCTION getReminderServices( varchar ) RETURNS SETOF reminder_services AS' DECLARE r reminder_services%ROWTYPE; BEGIN PERFORM dblink_connect(''dbname=''||$1); PERFORM dblink_disconnect($1); RETURN; END; ' LANGUAGE plpgsql; Now I get the er

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Loredana Curugiu
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,

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Richard Huxton
Loredana Curugiu wrote: I created the following function CREATE OR REPLACE FUNCTION getReminderServices( varchar ) RETURNS SETOF reminder_services AS' DECLARE r reminder_services%ROWTYPE; BEGIN SELECT dblink_connect(''dbname=''||$1); ^^^ and I get th

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Loredana Curugiu
I created the following function CREATE OR REPLACE FUNCTION getReminderServices( varchar ) RETURNS SETOF reminder_services AS' DECLARE r reminder_services%ROWTYPE; BEGIN SELECT dblink_connect(''dbname=''||$1); FOR r IN SELECT * FROM dblink(''SELECT * FROM reminder_services'')

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Bart Degryse
What Pavel mentions might indeed be an issue, but I think there's another one too. I think you have to call your function giving more information to the statement on what types will be returned. Since you use dblink I assume that the table or view reminder_services you are basically selecting fr

Re: [SQL] dblink inside plpgsql function

2007-07-03 Thread Pavel Stehule
Hello Every SELECT statement in PL/pgSQL have to be forward to variables. In plpgsql you can you use select only like select into variables columns from ... propably better version is (i haven't installed dblink and can't to test it) CREATE OR REPLACE FUNCTION GetReminderServices( varchar ) RE

[SQL] dblink inside plpgsql function

2007-07-03 Thread Loredana Curugiu
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,