Last active
September 10, 2016 21:57
-
-
Save mauricioprado00/6aaaa18d750a6ffe52ea6567301fed6f to your computer and use it in GitHub Desktop.
dinamically reading tables postgresql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
create function test(tablename text) RETURNS void as $$ | |
DECLARE | |
r text; | |
BEGIN | |
raise notice 'reading from: %', tablename; | |
FOR r IN execute ('SELECT sid FROM ' || tablename) | |
LOOP | |
-- can do some processing here | |
raise notice 'sid readed: %', r; | |
END LOOP; | |
END; | |
$$ LANGUAGE plpgsql; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment