当我使用此sql测试json_populate_recordset时,没有错误:
select 'name',(json_populate_recordset(null::"trn_rebatesys_20mstcontractdetail",'[
{
"s_line_no":1,
"departmentcd":30,
"catagorycd":2,
"jan":"",
"seriescd":"",
"f_exclude":0
}
]')).s_line_no,(json_populate_recordset(null::"trn_rebatesys_20mstcontractdetail",'[
{
"s_line_no":1,
"departmentcd":30,
"catagorycd":2,
"jan":"",
"seriescd":"",
"f_exclude":0
}
]')).departmentcd
但是当我将第二个"departmentcd":30
更改为"departmentcd":""
时,
错误消息说Error: type integer input syntax is invalid: ""
,如何解决?如何处理空字符串?
答案 0 :(得分:1)
您可以使用null
关键字
select json_populate_recordset(null::"test",'[{"id":null, "title":null}]');
json_populate_recordset
-------------------------
(,)
(1 row)