I have a column in my postgres DB called metadata which stores a JSON string, and the type is TEXT.
I'm trying to run a query to update a field named myCount inside the JSON. I'm using Spring Boot and JDBC.
String query = "UPDATE " + mTableName + " SET metadata = jsonb_set(metadata::jsonb, '{myCount}', ?)::text" +
" WHERE scope = ?";
PreparedStatement preparedStmt = jdbcTemplate.getDataSource().getConnection().prepareStatement(query);
preparedStmt.setInt (1, myCount);
preparedStmt.setString(2, scope);
// execute the java preparedstatement
return preparedStmt.executeUpdate();
I got the following error: ERROR: function jsonb_set(jsonb, unknown, integer) does not
Any ide ahow I can run a query that updates the myCount column inside the JSON?
jsonb_set(), so how are you going to test this code?json(function jsonb_set(jsonb, text[], integer) does not exist)