postgres 函数的 json 参数

Uda*_*ddy 8 postgresql json

CREATE OR REPLACE FUNCTION public.writecalculations(id integer, times integer, j json)
  RETURNS text
  LANGUAGE plv8
AS
$body$
var overallStart = new Date();
  var result = 0;
  var insertStmt = "Insert into \"CalculationResult\" Values($1,$2,$3::json)"
  result += plv8.execute(insertStmt,[id, times, j]);     

  var loopEnd = new Date();
  return JSON.stringify({"AffectedRows": result,  "OverallRuntime": loopEnd-overallStart}) ;
$body$
 IMMUTABLE STRICT
 COST 100;


COMMIT;
Run Code Online (Sandbox Code Playgroud)

使用以下命令执行时会出现错误

WbCall calculationResult(4,4,'{\"a\":1}');
Run Code Online (Sandbox Code Playgroud)

错误 :

执行SQL命令时发生错误:错误:函数计算结果(整数,整数,未知)不存在提示:没有函数与给定名称和参数类型匹配。您可能需要 > 添加显式类型转换。位置:15 [SQL 状态=42883]

我究竟做错了什么?我尝试了用“”和''传递文本以及传递json的各种选项

Har*_*lam 8

尝试:

WbCall calculationResult(4,4,'{"a":1}'::json);
Run Code Online (Sandbox Code Playgroud)

计算结果(整数,整数,未知) - PostgreSQL 没有检测到 '{"a":1}' 的类型,因此它要求您添加显式类型转换。