postgresql : **ERROR: path element at position 1 is not an integer:** I am trying to update a field value in jsonb column with text value present in another column but getting some syntax errors; not getting any solution.
i am trying to swap values of OutgoingVertexid &amp; IncomingVertexId in below JSONB
'[
      {
         &quot;Edgeid&quot;:10,
         &quot;Weight&quot;:100,
         &quot;Active&quot;:1,
         &quot;OutgoingVertexid&quot;:&quot;&quot;,
         &quot;IncomingVertexid&quot;:&quot;G&quot;,
         &quot;EdgeColor&quot;:&quot;Black&quot;
      }
   ]
'

so used below code by putting all values OutgoingVertexid &amp; IncomingVertexid value in temp table.
UPDATE temp_table 
        SET 
        owner_property = CASE 
                            WHEN owner_outgoing_edge IS NOT NULL 
                                THEN jsonb_set(owner_property, '{OutgoingVertexid}', '&quot;&quot;')
                            ELSE 
                                jsonb_set(owner_property, '{OutgoingVertexid}', ''||owner_incoming_edge::jsonb||'') 
                                END;

but getting below error:
ERROR: path element at position 1 is not an integer:
Thanks in Advance
Your json value is an array, not a single value. So you need to pick the array element you want to change by including the index in the array you pass to jsonb_set()
UPDATE temp_table 
  SET owner_property = CASE 
                        WHEN owner_outgoing_edge IS NOT NULL 
                          THEN jsonb_set(owner_property, '{0, OutgoingVertexid}', '&quot;&quot;')
                        ELSE 
                          jsonb_set(owner_property, '{0, OutgoingVertexid}', to_jsonb(owner_incoming_edge)) 
                       END