Last active
January 29, 2020 10:21
-
-
Save imidsac/ae93eafa191fb0ea982f5510a6bf266c to your computer and use it in GitHub Desktop.
Revisions
-
imidsac renamed this gist
Jan 29, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
imidsac revised this gist
Jan 29, 2020 . 2 changed files with 16 additions and 20 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,20 +0,0 @@ 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ CREATE OR REPLACE FUNCTION f_insert_date_series_of_bookingItems(BIGINT, DATE, DATE, CHARACTER VARYING, DECIMAL) RETURNS INTEGER LANGUAGE plpgsql AS $_$DECLARE r RECORD; s NUMERIC; BEGIN -- s = $2; FOR r IN SELECT generate_series($2 :: DATE, $3, $4::INTERVAL) :: DATE AS mdate OFFSET 1 LOOP INSERT INTO booking_items (booking_id, date_of_dues, amount, created_at, updated_at) VALUES ($1, r.mdate, $5, now() :: TIMESTAMP WITHOUT TIME ZONE, now() :: TIMESTAMP WITHOUT TIME ZONE); END LOOP; RETURN 1; END;$_$; -
imidsac created this gist
Jan 28, 2020 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,20 @@ CREATE OR REPLACE FUNCTION f_date_series() RETURNS INTEGER LANGUAGE plpgsql AS $_$DECLARE r RECORD; s NUMERIC; BEGIN -- s = $2; FOR r IN SELECT generate_series( (DATE '2020-01-31'), (DATE '2021-01-31'), INTERVAL '1 month' ) :: DATE AS mdate LIMIT 12 LOOP INSERT INTO booking_items (booking_id, date_of_dues, amount, created_at, updated_at) VALUES (1, r.mdate, 0, '2017-03-17 02:09:30', '2017-03-17 02:09:30'); END LOOP; RETURN 1; END;$_$;