Last active
September 27, 2018 07:56
-
-
Save beginor/3bb328bf7d74ddac00f924c077a7163d to your computer and use it in GitHub Desktop.
postgres for loop
This file contains hidden or 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
| DO $$ | |
| DECLARE | |
| st_time TIMESTAMP WITH TIME ZONE := '2016-03-01'; | |
| p RECORD; | |
| BEGIN | |
| RAISE INFO 'stat time is: % :', st_time; | |
| FOR p IN | |
| SELECT | |
| r.id, r.water_source_code, r.water_source_name | |
| FROM public.water_source_month_report r | |
| WHERE r.stat_time = st_time and r.water_source_code <> '' | |
| LOOP | |
| RAISE INFO '%', p; | |
| END LOOP; | |
| END $$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment