title: Postgres Insert select using WITH clause
body: <p>I'm trying to create some entries by using an <code>INSERT ... SELECT ...</code>, but also need to use the primary key from the 1st <code>INSERT</code> operation to be included as part of a secondary operation:</p>
  <pre><code>WITH dogEntries as (INSERT INTO dog (id, another_id, name, date_created)
      SELECT public.uuid_generate_v4(), 'efd55343', name, date_created
      FROM dog WHERE owner_id = '8921571' RETURNING id as dog_uuid)
  
  INSERT INTO dog_toys (dog_id, bed_id, status)
  SELECT (SELECT dog_uuid FROM dogEntries), bed_id, status FROM dog_toys 
  WHERE dog_id IN(SELECT dog_id FROM dogs WHERE another_id = '21571');
  </code></pre>
  <p><strong>public.uuid_generate_v4()</strong> will generate the id column.</p>
  <p>But I'm getting an error, not sure but I guess is because the <code>WITH dogEntries</code> is of course returning multiple entries.</p>
  <p><strong>The error:</strong></p>
  <blockquote>
  <p>[21000] ERROR: more than one row returned by a subquery used as an
  expression</p>
  </blockquote>
  <p>Is there any alternative of returning and iterate over the dog table inserted rows, or maybe a hint on how to traverse each of the entries from the <code>WITH dogEntries</code> statement?</p>