Re: [Feature Request] Support INSERT ... FROM ... TO for date ranges - Mailing list pgsql-hackers

From Álvaro Herrera
Subject Re: [Feature Request] Support INSERT ... FROM ... TO for date ranges
Date
Msg-id 202507171201.7sbg23ddxj5o@alvherre.pgsql
Whole thread Raw
In response to [Feature Request] Support INSERT ... FROM ... TO for date ranges  (zkbp712 <zkbp712@proton.me>)
List 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)



pgsql-hackers by date:

Previous
From: "yexiu-glory"
Date:
Subject: PostgreSQL 16 bug feedback
Next
From: Aleksander Alekseev
Date:
Subject: Re: [PATCH] Add tests for binaryheap.c