Re: Need help with this Function. I'm getting an error - Mailing list pgsql-novice

From ssharma
Subject Re: Need help with this Function. I'm getting an error
Date
Msg-id 1402852958408-5807338.post@n5.nabble.com
Whole thread Raw
In response to Re: Need help with this Function. I'm getting an error  (David G Johnston <david.g.johnston@gmail.com>)
Responses Re: Need help with this Function. I'm getting an error  (Gerald Cheves <gcheves@verizon.net>)
List pgsql-novice
Thanks for your response and sorry for my late response. Was away from my
machine. I used your suggestion to complete do away with the union and
instead used the for loop. Also I did not use a temp table or return next. I
got it to work with return query instead. Here's what it looks like:

-- Function: foo_bar()

-- DROP FUNCTION foo_bar();

CREATE OR REPLACE FUNCTION foo_bar()
  RETURNS SETOF detailed_phone_inventory_type AS
$BODY$
DECLARE
    v_iter_sys_id bigint ;

BEGIN
    FOR v_inter_sys_id IN SELECT distinct system_id FROM
inventory_system_properties

        LOOP
                return query
        (select
        A.company_name, A.id as system_id,A.name as system_name,B.* from
        fetch_cucm_systems() as A
        cross join
         (     SELECT t1.devicepkid,
​[lots more columns]

    FROM dblink('dbname=db'||v_iter_sys_id||' user=blah
password=blah123'::text, 'select * from
​​
v_detailed_phone_inventory'::text) t1(devicepkid text,
​[lots more columns]
)
                ) as B
                        where A.id=v_iter_sys_id::bigint);
END LOOP;
    RETURN;
END;
$BODY$






--
View this message in context:
http://postgresql.1045698.n5.nabble.com/Need-help-with-this-Function-I-m-getting-an-error-tp5806884p5807338.html
Sent from the PostgreSQL - novice mailing list archive at Nabble.com.


pgsql-novice by date:

Previous
From: Jason Whitener
Date:
Subject: Re: Upgraded, now permission denied.
Next
From: Gerald Cheves
Date:
Subject: Re: Need help with this Function. I'm getting an error