postgresql - How is compiled PL/pgSQL block? -


   $$   declare     tm1 timestamp without time zone;    tm2 timestamp without time zone;   begin      select localtimestamp(0) tm1;      in 1..200000000 loop         --just waiting several second      end loop;      select localtimestamp(0) tm2;        raise notice '% ; %', tm1, tm2;   end;   $$ language plpgsql 

why gives procedure same values tm1 , tm2 ?

is not executed code step step?

from manual

these sql-standard functions return values based on start time of current transaction [...] since these functions return start time of current transaction, values do not change during transaction. considered feature: intent allow single transaction have consistent notion of "current" time, multiple modifications within same transaction bear same time stamp

(emphasis mine)

you want clock_timestamp()


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -