1

Table has a json-column named "stats" with the following value: {"countValue":0}

I'm trying to update this value by:

 UPDATE my_table
 SET stats = jsonb_set(stats, '{countValue}', 1);

But receive the following error:

 No function matches the given name and argument types. You might need to add explicit type casts.

I tried to fix the problem, by applying explicit type cast for countValue (countValue::text), but with the same result.

What am I doing wrong?

1 Answer 1

1

You might need to use jsonb type on '1' instead of integer from jsonb_set function signature

jsonb_set(target jsonb, path text[], new_value jsonb [, create_missing boolean])

UPDATE my_table
SET stats = jsonb_set(stats, '{countValue}', '1');

sqlfiddle

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.