Re: [Feature Request] Support INSERT ... FROM ... TO for date ranges

From: Álvaro Herrera <alvherre(at)kurilemu(dot)de>
To: zkbp712 <zkbp712(at)proton(dot)me>
Cc: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: [Feature Request] Support INSERT ... FROM ... TO for date ranges
Date: 2025-07-17 12:01:06
Message-ID: 202507171201.7sbg23ddxj5o@alvherre.pgsql
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 2025-Jul-17, zkbp712 wrote:

> Alternative (optional) syntax idea:
>
> INSERT INTO dosage (medication_id, amount, date)
> GENERATE RANGE (5, 3, '2025-04-01', '2025-04-30');

Here's a simple way to achieve this:

INSERT INTO dosage(medication_id, amount, date)
SELECT 5, 3, g
FROM generate_series(date '2025-04-01', '2025-04-30', '1 day') AS g;

No new features are needed.

--
Álvaro Herrera Breisgau, Deutschland — https://www.EnterpriseDB.com/
"Nunca se desea ardientemente lo que solo se desea por razón" (F. Alexandre)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Aleksander Alekseev 2025-07-17 12:03:55 Re: [PATCH] Add tests for binaryheap.c
Previous Message yexiu-glory 2025-07-17 11:41:31 PostgreSQL 16 bug feedback