title: Store and reuse value returned by INSERT ... RETURNING
body: <p>In PostgreSQL, it is possible to put <code>RETURNING</code> at the end of an <code>INSERT</code> statement to return, say, the row's primary key value when that value is automatically set by a <code>SERIAL</code> type.</p>
  
  Question:
  
  <p>How do I store this value in a variable that can be used to insert values into other tables?
  Note that I want to insert the generated <code>id</code> into multiple tables. A <code>WITH</code> clause is, as far as I understand, only useful for a single insert. I take it that this will probably have to be done in PHP.</p>
  
  <p>This is really the result of bad design; without a natural key, it is difficult to grab a unique row unless you have a handle on the primary key;</p>