Скромное обаяние Postgre 0
Наткнулся сегодня на приятную фишку PostgreSQL (начиная с 8.2): RETURNING clause в INSERT-запросе. Долой вазюканье с currval и select! Даешь все в одном запросе!
The optional RETURNING clause causes INSERT to compute and return value(s) based on each row actually inserted. This is primarily useful for obtaining values that were supplied by defaults, such as a serial sequence number. However, any expression using the table’s columns is allowed. The syntax of the RETURNING list is identical to that of the output list of SELECT.