函数 json_populate_record(..., text) 不存在

And*_*iot 5 postgresql-9.3

我参考了文档中的示例,它运行良好:

select * from json_populate_record(null::x, '{"a":1,"b":2}')
Run Code Online (Sandbox Code Playgroud)

但是我自己构建的 JSON 简化类似于这样没有工作:-(

-- p_some_num of type int
select * from json_populate_record( null:my_record_type, '{"a":'||p_some_num||'',"b":2}' )
Run Code Online (Sandbox Code Playgroud)

导致:

ERROR: function json_populate_record(my_record_type, text) does not exist
Run Code Online (Sandbox Code Playgroud)

And*_*iot 3

我应该更仔细地阅读,并且不知道示例中隐含的text转换json。经过一番摆弄错误之后,当然可以进行以下操作:

select * from json_populate_record( 
  null:my_record_type, ('{"a":'||p_some_num||'',"b":2}')::json )
Run Code Online (Sandbox Code Playgroud)

  • 在此示例中,您使用什么作为“my_record_type”? (2认同)