Guest User

Untitled

a guest
Dec 22nd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. CREATE OR REPLACE FUNCTION get_data_from_server()
  2. RETURNS SETOF sometype AS
  3. $BODY$
  4. declare
  5. connx text;
  6. tempval text;
  7. rs record;
  8. result sometype;
  9. begin
  10. for rs in select server_ip_address,ist_id from ip_server_table
  11. loop
  12.  
  13. SELECT (extract(year from localtimestamp)::text || extract(month from localtimestamp) || extract(day from localtimestamp) || extract(hour from localtimestamp) || extract(minute from localtimestamp) || extract(second from localtimestamp) || extract(ms from localtimestamp) ) || ist_id INTO connx;
  14. select into tempval dblink_connect(connx, 'hostaddr=' || rs.server_ip_address || ' dbname=somedatabase user=someuser password=somepassword port=5432');
  15. if tempval = 'OK' then
  16. --fetch data
  17. end if;
  18.  
  19. end loop;
  20. end;
  21. $BODY$
  22. LANGUAGE plpgsql VOLATILE;
Add Comment
Please, Sign In to add comment