Last active
January 29, 2020 10:21
-
-
Save imidsac/ae93eafa191fb0ea982f5510a6bf266c to your computer and use it in GitHub Desktop.
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 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;$_$; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment