[英]Update timestamp in jsonb postgres
如何將 jsonb 中的時間戳更新為函數 now() 的值?
我試着像這樣做 smt
UPDATE test
SET column = jsonb_set(column,'{time}',to_char(now(),'some date format'),true)
我得到了錯誤
'jsonb_set(json,unknown,text,bool) is not available'
我認為錯誤的原因是 now() 的值不是單引號,因為這個查詢正在工作
UPDATE test
SET column = jsonb_set(column,'{time}','date with the same date format ',true)
有什么解決辦法嗎?
jsonb_set(json,unknown,text,bool) is not available
PostgreSQL 找不到具有此簽名的函數。 根據文檔,簽名是jsonb_set(jsonb, text[], jsonb, boolean)
。
to_char()
正在返回text
,您需要使用jsonb
,並且演員表應該可以解決問題:
jsonb_set(column, '{time}', to_char(now(),'\"some date format\"')::jsonb, true)
(請記住, ::jsonb
需要有效的 JSON 作為輸入,例如"
圍繞字符串。)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.