Postgresql 错误没有函数与给定的名称和参数类型匹配。您可能需要添加显式类型转换

Kse*_*aya 3 postgresql

declare r double precision; b double precision; c double precision;
begin

  r:=9.2;
  b:=2.3;
  c:=r/b;

  select log(2.7, c);
  ...
Run Code Online (Sandbox Code Playgroud)

但我收到此代码的错误:

错误:函数 log(numeric, double precision) 不存在 第 1 行:选择 log(2.7, c)

提示:没有函数与给定的名称和参数类型匹配。您可能需要添加显式类型转换。

查询:选择 log(2.7, c) 上下文:SQL 语句处的 PL/pgSQL 函数 inline_code_block 第 11 行 SQL 状态:42883

小智 5

如手册中所述,log()具有两个参数的函数numeric不需要double precision

do
$$
declare
  r numeric; 
  b numeric; 
  c numeric;
  result numeric;
begin

  r:=9.2;
  b:=2.3;
  c:=r/b;

  result := log(2.7, c);
  raise notice 'Result %', result;
end;
$$
Run Code Online (Sandbox Code Playgroud)