title: Insert data in multiple tables at a time with repeated values
body: <p>I have to insert data into first and second table directly. But the third table which I received data as array and inserted into 3rd table as same. </p>
  
  <p>In my 3rd table values will be repeated. Ex:</p>
  
  <p>values:</p>
  
  <pre><code>{name=ff,age=45,empid=23,desig=se,offid=1,details=kk,offid=2,details=aa,offid=3,details=bb,offid=4,details=cc}
  </code></pre>
  
  <p>So using 2nd table <code>userid</code> as same for all the <code>offid</code>, but details and other columns are different</p>
  
  <p><strong>@My issue is i will get single hit but i need to iterate for 3rd table.</strong></p>
  
  <pre><code>with first_insert as (
     insert into sample(name,age)
     values(?,?)
     RETURNING id
     ),
  second_insert as (
     insert into sample1(empid,desig)
     values((select id from first_insert),?)
     RETURNING userid
     )
  insert into sample2(offid,details)
  values((select userid from second_insert),?)
  </code></pre>
  
  <p>Is this available or possible in PostgreSQL?</p>