Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Postgresql 如何编译PL/pgSQL块?_Postgresql_Plpgsql_Postgresql 9.4 - Fatal编程技术网

Postgresql 如何编译PL/pgSQL块?

Postgresql 如何编译PL/pgSQL块?,postgresql,plpgsql,postgresql-9.4,Postgresql,Plpgsql,Postgresql 9.4,为什么为tm1和tm2提供相同的值 这个代码不是一步一步执行的吗 这些SQL标准函数都基于当前事务的开始时间返回值[…],因为这些函数返回当前事务的开始时间,所以它们的值在事务期间不会更改。这被认为是一个特性:其目的是允许单个事务具有“当前”时间的一致概念,以便同一事务中的多个修改具有相同的时间戳 (强调矿山) 您可能需要clock\u timestamp() do $$ declare tm1 timestamp without time zone; tm2 time

为什么为
tm1
tm2
提供相同的值

这个代码不是一步一步执行的吗

这些SQL标准函数都基于当前事务的开始时间返回值[…],因为这些函数返回当前事务的开始时间,所以它们的值在事务期间不会更改。这被认为是一个特性:其目的是允许单个事务具有“当前”时间的一致概念,以便同一事务中的多个修改具有相同的时间戳

(强调矿山)

您可能需要
clock\u timestamp()

   do $$
  declare 
   tm1 timestamp without time zone;
   tm2 timestamp without time zone;
  begin
     select localtimestamp(0) into tm1;
     for i in 1..200000000 loop
        --just waiting several second
     end loop;
     select localtimestamp(0) into tm2;

      raise notice '% ; %', tm1, tm2;
  end;
  $$ language plpgsql