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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -