title: How to return another value from WITH clause after Inserting
body: <p>I try to use With clauses to make insertion to another table. I can return the id from the final query but the main goal is to get name of the adapter.</p>
  <pre><code>With AdapterName as (Select CONCAT('s', LTRIM(name, 's')::integer+1) as new_name
                       From adapter
                       Where adapter.name LIKE 's%'
                       Order by id desc
                       Limit 1),
       AdapterIns as (INSERT INTO adapter (create_date,name,tag) SELECT now(),new_name, new_name From AdapterName RETURNING id,name)
  INSERT INTO user_adapter (create_date, user_id, adapter_id)
  Select now(), 1, AdapterIns.id
  From AdapterIns
  RETURNING adapter_id;
  </code></pre>
  <p>How can I return AdapterIns.name as a final result?</p>
  <p>Thanks,</p>
  <p><strong>Update</strong>: I also tried joining the adapter_id with original table but getting following error for the latest INSERT:</p>
  <blockquote>
  <p>[42601] ERROR: syntax error at or near &quot;INSERT&quot;</p>
  </blockquote>
  <pre><code>Select adapter.name
  From adapter
          Join (With AdapterName as (Select CONCAT('s', LTRIM(name, 's')::integer+1) as new_name
                                            From adapter
                                            Where adapter.name LIKE 's%'
                                            Order by id desc
                                            Limit 1),
                            AdapterIns as (INSERT INTO adapter (create_date,name,tag) SELECT now(),new_name, new_name From AdapterName RETURNING id)
                       INSERT INTO user_adapter (create_date, user_id, adapter_id)
                       Select now(), 1, AdapterIns.id
                       From AdapterIns
                           RETURNING adapter_id) temp on adapter.id = temp.adapter_id;
  </code></pre>