title: How to use scalar to copy value from one field to another?
body: <p>I have table with <code>jsonb</code> column &quot;Details&quot;:</p>
  <pre><code>{&quot;Type&quot;: &quot;VIP&quot;, &quot;Quantity&quot;: 1}
  </code></pre>
  <p>I want update column, using query that copies value from <code>&quot;Type&quot;</code> field to new one <code>&quot;Subscription&quot;</code> and change value &quot;VIP&quot;-&gt;2. Exp below:</p>
  <pre><code>{&quot;Type&quot;: 2, &quot;Quantity&quot;: 1, &quot;Subscription&quot;: &quot;VIP&quot;}
  </code></pre>
  <p>I have tried script but received error &quot;Can't extract scalar value&quot;</p>
  <pre><code>Update &quot;Media&quot; set &quot;Details&quot; = jsonb_set(&quot;Details&quot;, '{Subscription}'::text[],
              (select res.value from jsonb_array_elements(&quot;Details&quot; -&gt; 'Type') as res), true)
  </code></pre>
  <p>What is wrong? Please, help to find a solution.</p>