CREATE TABLE test(id serial, data jsonb); INSERT INTO test(data) values ('dummydata-got-uploaded');
I need to correct the jsonb column value with below query.
update test set data={"addDet": data }::jsonb where id =1;
ERROR: syntax error at or near “{”
LINE 1: update test set data={“addDet”: data…
Expected:
id | data
1 | {"addDet": 'dummydata-got-uploaded' }
`
Thanks in advance.
Advertisement
Answer
you might want to have a look at json_build_object
function
update test set data=json_build_object('addDet', data )::jsonb where id =1;