AW: SQL - How to iterate with delay in a loop

From: "Subramanian,Ramachandran" <ramachandran(dot)subramanian(at)alte-leipziger(dot)de>
To: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>, "pgsql-novice(at)lists(dot)postgresql(dot)org" <pgsql-novice(at)lists(dot)postgresql(dot)org>
Subject: AW: SQL - How to iterate with delay in a loop
Date: 2026-03-06 18:24:01
Message-ID: 7638801a4dc64c26bb2196607d1b48cc@alte-leipziger.de
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Thank you so much. That worked perfectly. 😊

LG

Ram

id_column | saved_ts_no_tz | saved_ts_with_tz | saved_date | saved_time
-----------+----------------------------+-------------------------------+------------+-----------------
20 | 2026-03-06 19:22:18.992382 | 2026-03-06 19:22:18.992384+01 | 2026-03-06 | 19:22:18.992385
21 | 2026-03-06 19:22:19.993481 | 2026-03-06 19:22:19.993484+01 | 2026-03-06 | 19:22:19.993485
22 | 2026-03-06 19:22:20.99458 | 2026-03-06 19:22:20.994583+01 | 2026-03-06 | 19:22:20.994584
23 | 2026-03-06 19:22:21.994803 | 2026-03-06 19:22:21.994806+01 | 2026-03-06 | 19:22:21.994806
24 | 2026-03-06 19:22:22.995918 | 2026-03-06 19:22:22.99592+01 | 2026-03-06 | 19:22:22.995921
25 | 2026-03-06 19:22:23.997049 | 2026-03-06 19:22:23.997051+01 | 2026-03-06 | 19:22:23.997052
26 | 2026-03-06 19:22:24.997807 | 2026-03-06 19:22:24.997809+01 | 2026-03-06 | 19:22:24.997809
27 | 2026-03-06 19:22:25.998923 | 2026-03-06 19:22:25.998926+01 | 2026-03-06 | 19:22:25.998927

Freundliche Grüße

i. A. Ramachandran Subramanian
Zentralbereich Informationstechnologie

Alte Leipziger Lebensversicherung a.G.

Hallesche Krankenversicherung a.G.

Alte Leipziger Lebensversicherung a.G., Alte Leipziger-Platz 1, 61440 Oberursel
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape, Wiltrud Pekarek, Udo Wilcsek
Sitz Oberursel (Taunus) · Rechtsform VVaG · Amtsgericht Bad Homburg v. d. H. HRB 1583 · USt.-IdNr. DE 114106814


Hallesche Krankenversicherung a.G., Löffelstraße 34-38, 70597 Stuttgart
Vors. des Aufsichtsrats: Dr. Walter Botermann · Vorstand: Christoph Bohn (Vors.), Dr. Jürgen Bierbaum (stv. Vors.), Frank Kettnaker, Dr. Jochen Kriegmeier, Alexander Mayer, Christian Pape,
Wiltrud Pekarek, Udo Wilcsek
Sitz Stuttgart · Rechtsform VVaG · Amtsgericht Stuttgart HRB 2686 · USt.-IdNr. DE 147802285
Beiträge zu privaten Kranken- und Pflegekrankenversicherungen unterliegen nicht der Versicherungsteuer (§ 4 Nr. 5 VersStG) · Versicherungsleistungen sowie Umsätze aus Versicherungsvertreter-/Maklertätigkeiten sind umsatzsteuerfrei


Die Pflichtangaben der ALH Gruppe gemäß § 35a GmbHG bzw. § 80 AktG finden Sie hier: https://www.alte-leipziger.de/impressum

______________________

ALH Gruppe
Alte Leipziger-Platz 1, 61440 Oberursel
Tel.: +49 (6171) 66-4882
Fax: +49 (6171) 66-800-4882
E-Mail: ramachandran(dot)subramanian(at)alte-leipziger(dot)de
www.alte-leipziger.de
www.hallesche.de

-----Ursprüngliche Nachricht-----
Von: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Gesendet: Freitag, 6. März 2026 14:21
An: Subramanian,Ramachandran IT-md-db <ramachandran(dot)subramanian(at)alte-leipziger(dot)de>; pgsql-novice(at)lists(dot)postgresql(dot)org
Betreff: Re: SQL - How to iterate with delay in a loop

On Fri, 2026-03-06 at 12:07 +0000, Subramanian,Ramachandran wrote:
> I am trying to insert some rows into a table with a delay between each insert.
> I have a simple table with a ID column and some Date-Time columns.
>  
> The first two inserts work as expected and insert two rows, each one second apart.
>  
> However the do loop inserts 25 more rows, with the same timestamp.

Use clock_timestamp()::time instead of current_time.
current_time returns the same value for each call in the same database transaction. Think of it as "transaction start time".

Yours,
Laurenz Albe

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Subramanian,Ramachandran 2026-03-12 08:54:04 Is it possible to turn on pg_stat_extensions at a database level
Previous Message Laurenz Albe 2026-03-06 13:20:58 Re: SQL - How to iterate with delay in a loop