Created
December 22, 2016 19:11
-
-
Save edib/69b5dbea2159d6516e95362bb1d002b5 to your computer and use it in GitHub Desktop.
insert function for postgresql partition tutorial in https://www.if-not-true-then-false.com/2009/howto-create-postgresql-table-partitioning-part-1/
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
| CREATE OR REPLACE FUNCTION insert_date(INTEGER,INTEGER,DATE) RETURNS VOID AS $$ | |
| DECLARE | |
| mystart alias for $1; | |
| myend alias for $2; | |
| mydate alias for $3; | |
| BEGIN | |
| FOR i IN mystart..myend LOOP | |
| INSERT INTO impressions_by_day values(i,mydate,round(random()*10000)); | |
| END LOOP; | |
| END; | |
| $$ LANGUAGE 'plpgsql' STRICT; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment