title: postgresql: nested insert
body: <p>I have two tables. Lets say tblA and tblB.<br>
  I need to insert a row in tblA and use the returned id as a value to be inserted as one of the columns in tblB.  </p>
  
  <p>I tried finding out this in documentation but could not get it. Well, is it possible to write a statement (intended to be used in prepared) like  </p>
  
  <pre><code>INSERT INTO tblB VALUES 
  (DEFAULT, (INSERT INTO tblA (DEFAULT, 'x') RETURNING id), 'y')
  </code></pre>
  
  <p>like we do for SELECT?  </p>
  
  <p>Or should I do this by creating a Stored Procedure?. I'm not sure if I can create a prepared statement out of a Stored Procedure.</p>
  
  <p>Please advise.  </p>
  
  <p>Regards,<br>
  Mayank</p>